Do Whle issue
wanting check if folder exists, if not, keep looping sayings not there yet; if , move on. why not working me? have misunderstanding how conditional logic of while loop works. i'm sure there plenty of easier ways this, , i'm game see suggestions, great if explain why logic below isn't sound? runs through 1 iteration, doesn't loop.
many thanks,
$stoploop = $false { if (test-path c:\path) { write-host 'folder exists';start-sleep -seconds 2 $stoploop = $true } else { write-host 'folder doesnt exist';start-sleep -seconds 2 } } while ($stoploop = $false)
hi,
this construct use:
$found = $false { if (test-path c:\path) { write-host 'path found!' -foregroundcolor green $found = $true } else { write-host 'not found yet.' -foregroundcolor red start-sleep -seconds 2 } } until ($found)
edit: answer initial question though, you're not using correct test in while statement. you'd need use while ($stoploop -eq $false). using = sets value $false, doesn't testing.
Windows Server > Windows PowerShell
Comments
Post a Comment