powershell - Loop X number of times -
i'm working on first powershell script , can't figure loop out. have following, repeat $activecampaigns number of times:
write-host "creating $pqcampaign1 pre-qualified report" invoke-item "$pqcampaignpath1\pq report $pqcampaign1.qvw" write-host "waiting 1 minute qlikview update" sleep -seconds 60 # wait 1 minutes qlikview reload, create report , save. do{ write-host "daily qlikview reports" write-host "wating qlikview create $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 $pqcampaign1 pq report. wait 10 seconds." sleep -seconds 10
these parameters need increase 1 each loop:
$pqcampaign1
(should become$pqcampaign2
, 3 etc.)$pqcampaignpath1
(should become$pqcampaignpath2
, 3 etc.)
so if $activecampaigns
set 8 on day, needs repeat 8 times , last time must open $pqcampaign3
lies in $pqcampaignpath8
.
can please help?
is looking for?
for ($i=1; $i -le $activecampaigns; $i++) { $pqcampaign = get-variable -name "pqcampaign$i" -valueonly $pqcampaignpath = get-variable -name "pqcampaignpath$i" -valueonly #do stuff $pqcampaign , $pqcampaignpath }
Comments
Post a Comment