共用方式為


Set-AzureSiteRecoveryProtectionEntity

設定 Site Recovery 保護實體的狀態。

注意

本文件中參考的 Cmdlet 用於管理使用 Azure Service Manager(ASM) API 的舊版 Azure 資源。 建立新的資源時,不建議使用此舊版 PowerShell 模組,因為 ASM 已排定淘汰。 如需詳細資訊,請參閱 Azure Service Manager 淘汰

Az PowerShell 模組是使用 PowerShell 管理 Azure Resource Manager (ARM) 資源的建議 PowerShell 模組。

語法

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

Set-AzureSiteRecoveryProtectionEntity Cmdlet 會在 Azure Site Recovery 保護實體上啟用或停用保護。

範例

範例 1:為容器中的物件啟用保護

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

第一個命令會使用 Get-AzureSiteRecoveryProtectionContainer Cmdlet 取得目前 Azure Site 保存庫的容器,然後將它儲存在$ProtectionContainer變數中。

第二個命令會使用 Get-AzureSiteRecoveryProtectionEntity Cmdlet,取得屬於儲存在 $ProtectionContainer 容器的受保護虛擬機。 命令會將結果儲存在 $ProtectionEntity 變數中。

最後一個命令可保護儲存在 $ProtectionEntity 中的實體。

參數

-Confirm

執行 Cmdlet 之前先提示您確認。

類型:SwitchParameter
別名:cf
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

-Force

強制命令執行,而不要求使用者確認。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Id

指定要啟用或停用保護之受保護虛擬機的標識碼。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-OS

指定作業系統類型。 此參數可接受的值為:

  • Windows
  • Linux
類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-OSDiskName

指定包含作業系統的磁碟名稱。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Profile

指定此 Cmdlet 從中讀取的 Azure 設定檔。 如果您未指定設定檔,此 Cmdlet 會從本機預設配置檔讀取。

類型:AzureSMProfile
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Protection

指定應該啟用或停用保護。 此參數可接受的值為:

  • 啟用
  • 停用
類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-ProtectionContainerId

指定受保護容器的標識碼。 此 Cmdlet 會啟用或停用屬於此參數所指定容器之虛擬機的保護。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-ProtectionEntity

指定保護實體物件。

類型:ASRProtectionEntity
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-ProtectionProfile

指定要啟用保護的保護配置檔。 指定 ASRProtectionProfile 物件,該對像是相關聯保護容器中其中一個可用的保護配置檔。

類型:ASRProtectionProfile
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-WaitForCompletion

表示 Cmdlet 會先等候作業完成,再將控制權傳回 Windows PowerShell 控制台。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。

類型:SwitchParameter
別名:wi
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False