1
$NewestFile = $NULL
$path = "C:\myDirectory"
$NewestFile = Get-ChildItem -filter “FileName*.xlsx” -recurse -path $path |
Sort LastWriteTime -Descending |
Select -First 1
Write-Host " NewestFile" $NewestFile
나는 거의 동일한 이름의 여러 파일을 가지고 있으며 처리를 위해 최신 파일을 선택하려고합니다. 이 명령 줄에서 실행하면 잘 작동하지만 동일한 코드는 powershell 스크립트에서 실행되지 않습니다.get-childitem 변수가 powershell 스크립트를 실행할 때 빈 값을 반환합니다.
오류 또는 예기치 않은 결과는 무엇입니까? –