In fact, the commands in PowerShell are processed one by one. So, if you just specify three commands responsible for starting corresponding jobs, everything will be ok. In other words, not until the first job is completed, will the PowerShell proceed to the second one, etc.:Are there sample scripts that show how to do all this in powershell? I.E. check status of jobs and then running them when predefind other jobs are finished?
Code: Select all
Asnp VeeamPSSnapin
Get-VBRJob -name "Backup Job 1" | Start-VBRJob
Get-VBRJob -name "Backup Job 2" | Start-VBRJob
Get-VBRJob -name "Backup Job 3" | Start-VBRJob
Code: Select all
Add-PSSnapin VeeamPSSnapin
$StartInfo = new-object System.Diagnostics.ProcessStartInfo
$StartInfo.FileName = "$pshome\powershell.exe"
$StartInfo.Arguments = ""
$StartInfo.WorkingDirectory = "C:\"
$StartInfo.LoadUserProfile = $true
$StartInfo.UseShellExecute = $true
$StartInfo.CreateNowindow = $False
$firstjob = Get-VBRJob -name "Backup Job 1"
$secondjob = Get-VBRJob -name "Backup Job 2"
$thirdjob = Get-VBRJob -name "Backup Job 3"
$StartInfo.Arguments = "-Command asnp VeeamPSSnapin; Get-VBRJob -name 'Backup Job 1' | Start-VBRJob"
[System.Diagnostics.Process]::Start($StartInfo)
Start-sleep -s 60
$status = $firstjob.GetLastState()
do
{
Start-sleep -s 30
$status = $firstjob.GetLastState()
}while ($status -eq "Working")
$StartInfo.Arguments = "-Command asnp VeeamPSSnapin; Get-VBRJob -name 'Backup Job 2' | Start-VBRJob"
[System.Diagnostics.Process]::Start($StartInfo)
Start-sleep -s 60
$status = $secondjob.GetLastState()
do
{
Start-sleep -s 30
$status = $secondjob.GetLastState()
}while ($status -eq "Working")
$StartInfo.Arguments = "-Command asnp VeeamPSSnapin; Get-VBRJob -name 'Backup Job 3' | Start-VBRJob"
[System.Diagnostics.Process]::Start($StartInfo)
Hope this helps.
Thanks.