Reputation: 37
Can someone please tell me what I'm doing wrong here, it's killing me... I want the loop to stop if it's been over a minute or SomeFile.txt shows up. Thanks
$EndTimer = (Get-Date).AddMinutes(1)
while (((Get-Date) -le $EndTimer) -or (!(Test-Path "$LocPath\SomeFile.txt"))) {2..1 | ForEach {Start-Sleep -Seconds $_ ;"Processing..."}}
Upvotes: 0
Views: 139
Reputation: 18156
You should be using -and
instead of -or
in your condition.
You want the loop to continue "while" the timer isn't expired and the file doesn't exist.
Upvotes: 2