Wait-AzureRmRecoveryServicesBackupJob

Waits for a Backup job to finish.

Syntax

Wait-AzureRmRecoveryServicesBackupJob
    [-Job] <Object>
    [[-Timeout] <Int64>]
    [-VaultId <String>]
    [-DefaultProfile <IAzureContextContainer>]
    [<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

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-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:System.Nullable`1[System.Int64]
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-VaultId

ARM ID of the Recovery Services Vault.

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

Inputs

Object

Parameters: Job (ByValue)

Inputs

String

Parameters: VaultId (ByValue)

Outputs

Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobBase