Here is my code:
#make sure deployment is in running state
$deployment = Get-AzureDeployment -servicename $_serviceName -slot $_slotName
Write-Host "$_serviceName is in state $($deployment.status)"
while ($deployment.Status -ne "running")
{
Write-Host "wait 5 seconds before trying again"
Start-Sleep -s 5
$deployment = Get-AzureDeployment -servicename $_serviceName -slot $_slotName
Write-Host "$_serviceName is in state $($deployment.status)"
}
I want to put a condition in the while loop that if it's been running for lets say 2 hours, then it should exit. Can't seem to find out how to start a timer and keep a record of it in powershell.
stopwatchand adding an additional condition via&&to yourwhileloop.