아래 코드에서 Get-ChildItem 뒤에 $ scanpath 변수를 사용하려고하면 어떤 이유로 인해 작동하지 않습니다. 그러나 $ scanpath 대신 실제 경로를 넣으면 작동합니다. 내가 도대체 뭘 잘못하고있는 겁니까? $ computer 변수와 $ savepath 변수 모두 잘 동작합니다.PowerShell - Invioke-Command에 변수 전달
$computer = 'Server'
$scanpath = 'P$\Directory\Directory\Z'
$savepath = 'C:\Z-Media.csv'
Invoke-Command -ComputerName $computer -scriptblock {Get-ChildItem $scanpath -recurse -include *.mp3,*.wma,*.wmv,*.mov,*.mpg,*.ogg,*.jpg -force | select FullName, Length | Sort-Object { [long]$_.Length } -descending} | Export-Csv $savepath -NoTypeInformation
"does not work"란 무엇을 의미합니까? PowerShell에서 오류 메시지가 나타나면 해당 메시지의 내용을 공유 할 수 있습니까? – MatthewG
빈 파일과 오류가 발생했습니다. – shank