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