아래 코드를 실행하면 다음과 같은 결과가 나타납니다. 이 코드를 실행하면와일드 카드 검색에서 출력을 표시하지 않습니다.
import-module activedirectory
Get-ADComputer -Filter {Name -Like "*1234*"} -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack -Wrap -Auto
Name OperatingSystem OperatingSystemServicePack
---- --------------- --------------------------
DEP12345LT
CLC41234DT Windows 7 Enterprise Service Pack 1
A123456 Windows 7 Enterprise Service Pack 1
는 그러나
import-module activedirectory
$assetid = Read-Host "Assest id"
Get-ADComputer -Filter {Name -Like "*$assetid*"} -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack -Wrap -Auto
나는
PS U:\> V:\General Helpful Scripts and Code\wild_card_pc_number_finder.ps1
Assest id: 1234
PS U:\>
시도 변수를 전달할 때 왜 결과를 표시하지 않습니다를 얻을?
쿨! 그것은 효과가있다! 그걸 평가할 수없는 이유가 있을까요? 왜 내가 먼저 문자열을 생성하고 그것을 전달해야하는지. – TuckRollworthy
@TuckRollworthy 내 답변을 업데이트하고 이것이 작동하지 않는 이유를 설명하려고했습니다. – Richard