我正在编写我的第一个 PowerShell 脚本,但无法弄清楚循环。
我有以下内容,它将重复$ActiveCampaigns次数:
Write-Host "Creating $PQCampaign1 Pre-Qualified Report"
Invoke-Item "$PQCampaignPath1\PQ REPORT $PQCampaign1.qvw"
Write-Host "Waiting 1 minute for QlikView to update"
sleep -seconds 60 # Wait 1 minute for QlikView to Reload, create Report and Save.
DO{
Write-Host "Daily Qlikview Reports"
Write-Host "Wating for QlikView to create the $PQCampaign1 PQ Report"
Get-Date
Write-Host "Checking...."
sleep -seconds 1
Write-Host ""
Write-Host "Not Done Yet"
Write-Host "Will try again in 5 seconds."
Write-Host ""
sleep -seconds 5
}
Until (Test-Path "$PQCampaignPath1\$PQCampaign1 $PQReportName $ReportDate.xlsx" -pathType leaf)
Get-Date
Write-Host "Done with $PQCampaign1 PQ Report. Wait 10 seconds."
sleep -seconds 10
这些参数需要为每个循环增加一个:
$PQCampaign1
(应该变成$PQCampaign2
,然后是 3 等等)$PQCampaignPath1
(应该变成$PQCampaignPath2
,然后是 3 等等)
所以如果$ActiveCampaigns
在某一天设置为 8,那么这需要重复 8 次,最后一次必须打开$PQCampaign3
,位于$PQCampaignPath8
.
我怎样才能解决这个问题?