2017-12-24 27 views
0

ジョブの出力前にRead-Host行の出力が表示されるのはなぜですか?代わりにあなたが$ScriptBlockForJobで最後の行を削除する場合、期待どおりStart-Jobが予期しない出力を生成しない

$WorkingDirectory = Get-Location 

$ScriptBlockForJob = {  
    Get-ChildItem $Input -Directory ` 
     | Where-Object ` 
      {$_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0} ` 
       | Select-Object FullName     
} 

Start-Job -InputObject $WorkingDirectory -ScriptBlock $ScriptBlockForJob | Wait-Job | Receive-Job 

Read-Host 'Above is a list of empty directories. Press enter to begin deleting them' 

The code above yields this ouput

答えて

0

は、コマンドが実行されます。

$ScriptBlockForJob = {  
    Get-ChildItem $Input -Directory ` 
     | Where-Object ` 
      {$_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0}        
} 

Output as expected

関連する問題