private void EnterpriseToEnterpriseDissociation() { if (string.Compare( this.ProtectionProfile.ReplicationProvider, Constants.HyperVReplica, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ProtectionProfile.ReplicationProvider)); } DisassociateProtectionProfileInput disassociateProtectionProfileInput = new DisassociateProtectionProfileInput(); disassociateProtectionProfileInput.PrimaryProtectionContainerId = this.PrimaryProtectionContainer.Name; disassociateProtectionProfileInput.RecoveryProtectionContainerId = this.RecoveryProtectionContainer.Name; disassociateProtectionProfileInput.Name = this.ProtectionProfile.Name; disassociateProtectionProfileInput.ReplicationProviderSettings = new ProtectionProfileProviderSpecificInput(); this.response = RecoveryServicesClient.DissociateAzureSiteRecoveryProtectionProfile( this.ProtectionProfile.Name, disassociateProtectionProfileInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteCmdlet() { try { string recoveryContainerId = string.Empty; recoveryContainerId = this.RecoveryProtectionContainer.ID; DisassociateProtectionProfileInput disassociateProtectionProfileInput = new DisassociateProtectionProfileInput(); disassociateProtectionProfileInput.PrimaryProtectionContainerId = this.PrimaryProtectionContainer.Name; disassociateProtectionProfileInput.RecoveryProtectionContainerId = this.RecoveryProtectionContainer.Name; disassociateProtectionProfileInput.Name = this.ProtectionProfile.Name; disassociateProtectionProfileInput.ReplicationProviderSettings = string.Empty; this.response = RecoveryServicesClient.DissociateAzureSiteRecoveryProtectionProfile( this.ProtectionProfile.Name, disassociateProtectionProfileInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); } catch (Exception exception) { this.HandleException(exception); } }