Set-AzureSiteRecoveryProtectionEntity

Sets the state for a Site Recovery protection entity.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

Set-AzureSiteRecoveryProtectionEntity
   -ProtectionEntity <ASRProtectionEntity>
   [-ProtectionProfile <ASRProtectionProfile>]
   -Protection <String>
   [-OSDiskName <String>]
   [-OS <String>]
   [-WaitForCompletion]
   [-Force]
   [-Profile <AzureSMProfile>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzureSiteRecoveryProtectionEntity
   -Id <String>
   -ProtectionContainerId <String>
   [-ProtectionProfile <ASRProtectionProfile>]
   -Protection <String>
   [-OSDiskName <String>]
   [-OS <String>]
   [-WaitForCompletion]
   [-Force]
   [-Profile <AzureSMProfile>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Set-AzureSiteRecoveryProtectionEntity cmdlet enables or disables protection on an Azure Site Recovery protection entity.

Examples

Example 1: Enable protection for objects in a container

PS C:\> $ProtectionContainer = Get-AzureSiteRecoveryProtectionContainer -Name "Cloud17"
PS C:\> $ProtectionEntity = Get-AzureSiteRecoveryProtectionEntity -ProtectionContainer $ProtectionContainer -Name "VM01"
PS C:\> Set-AzureSiteRecoveryProtectionEntity -ProtectionEntity $ ProtectionEntity -Protection Enable -ProtectionProfile $ProtectionContainer.AvailableProtectionProfiles[0] -OS Windows

The first command gets containers for the current Azure Site vault by using the Get-AzureSiteRecoveryProtectionContainer cmdlet, and then stores it in the $ProtectionContainer variable.

The second command gets the protected virtual machines that belong to the container stored in $ProtectionContainer by using the Get-AzureSiteRecoveryProtectionEntity cmdlet. The command stores the results in the $ProtectionEntity variable.

The final command enables protection for the entities stored in $ProtectionEntity.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Id

Specifies the ID of a protected virtual machine for which to enable or disable protection.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-OS

Specifies the operating system type. The acceptable values for this parameter are:

  • Windows
  • Linux
Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-OSDiskName

Specifies the name of the disk that contains the operating system.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Type:AzureSMProfile
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Protection

Specifies whether protection should be enabled or disabled. The acceptable values for this parameter are:

  • Enable
  • Disable
Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ProtectionContainerId

Specifies the ID of a protected container. This cmdlet enables or disables protection for a virtual machine that belongs to the container that this parameter specifies.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ProtectionEntity

Specifies the protection entity object.

Type:ASRProtectionEntity
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ProtectionProfile

Specifies a protection profile to enable protection. Specify an ASRProtectionProfile object that is one of the available protection profiles in the associated protection container.

Type:ASRProtectionProfile
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WaitForCompletion

Indicates that the cmdlet waits for the operation to complete before it returns control to the Windows PowerShell console.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False