1
這裏是我的代碼:在PowerShell腳本中使用時間條件循環
#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)"
}
我想提出一個條件,while循環,如果它已經運行了可以說2小時,然後就應該退出。似乎無法找到如何啓動計時器並在PowerShell中保存記錄。
您應該看看使用'stopwatch'並通過'&&'在'while'循環中添加附加條件。 – gravity