Wait-​Azure​Rm​Recovery​Services​Backup​Job

Waits for a Backup job to finish.

Syntax

Wait-AzureRmRecoveryServicesBackupJob
    [-Job] <Object>
    [[-Timeout] <Int64>]
    [<CommonParameters>]

Description

The Wait-AzureRmRecoveryServicesBackupJob cmdlet waits for an Azure Backup job to finish. Backup jobs can take a long time. If you run a backup job as part of a script, you may want to force the script to wait for job to finish before it continues to other tasks.

A script that includes this cmdlet can be simpler than one that polls the Backup service for the job status.

Set the vault context by using the Set-AzureRmRecoveryServicesVaultContext cmdlet before you use the current cmdlet.

Examples

Example 1: Wait for a job to finish

PS C:\>
$Jobs = Get-AzureRmRecoveryServicesBackupJob -Status InProgress
    $Job = $Jobs[0]
    while ( $Job.Status -ne Completed )
    {
       Write-Host "Waiting for completion..."
       Start-Sleep -Seconds 10
       $Job = Get-AzureRmBackAzureRmRecoveryServicesBackupJob -Job $Job
    }
   Write-Host "Done!"
    Waiting for completion... 
    Waiting for completion... 
    Waiting for completion... 
    Done!

This script polls the first job that is currently in progress until the job has completed.

Required Parameters

-Job

Specifies the job to wait for. To obtain a BackupJob object, use the Get-AzureRmRecoveryServicesBackupJob cmdlet.

Type:Object
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional Parameters

-Timeout

Specifies the maximum time, in seconds, that this cmdlet waits for the job to finish. It is recommended to specify a time-out value.

Type:Int64
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False