Last active
August 29, 2015 14:27
-
-
Save Dalmirog-zz/30cd4fe4ebde0a9d80ea to your computer and use it in GitHub Desktop.
Wait
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [string]$LockFile = "C:\Test\Lockfile.txt" | |
| [int]$wait = 15 #seconds to wait before checking the content of $lockfile again. | |
| #Creating $lockfile if it doesnt exist | |
| If ((Test-Path $LockFile) -eq $false){ | |
| Write-Output "$lockfile does not exist on $env:computername. Creating it..." | |
| New-Item $LockFile -ItemType file -Verbose | |
| "Available" | Out-File $LockFile | |
| } | |
| do{ | |
| $content = Get-Content $LockFile | |
| if($content -eq "Available"){ | |
| Write-Output "Content of $lockfile is 'Available'. Moving on to next step" | |
| $continue = $true | |
| } | |
| else{ | |
| Write-Output "Content of $lockfile is '$content' Checking again in $wait sec" | |
| Start-Sleep -Seconds $wait | |
| } | |
| }while($continue -ne $true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment