PowerShell Remove-Item not waiting
问题 If have this piece of code if(Test-Path -Path $OUT) { Remove-Item $OUT -Recurse } New-Item -ItemType directory -Path $OUT Sometimes it works, but sometimes the New-Item line produces a PermissionDenied ItemExistsUnauthorizedAccessError error. Which, I assume, means that the previous Remove-Item was not completely performed yet and the folder cannot be created because it still exists. If I insert a sleep there if(Test-Path -Path $OUT) { Remove-Item $OUT -Recurse Start-Sleep -s 1 } New-Item