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スクリプトで空の値を返します。
を入力してください。エラーまたは予期しない出力は何ですか? –