Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save Dalmirog-zz/30cd4fe4ebde0a9d80ea to your computer and use it in GitHub Desktop.

Select an option

Save Dalmirog-zz/30cd4fe4ebde0a9d80ea to your computer and use it in GitHub Desktop.
Wait
[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