@@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.SiteRecovery
23
23
/// <summary>
24
24
/// Adds Azure Site Recovery Policy settings to a Protection Container.
25
25
/// </summary>
26
- [ Cmdlet ( VerbsCommon . Remove , "AzureRmSiteRecoveryProtectionContainerMapping" , DefaultParameterSetName = ASRParameterSets . ByObject ) ]
26
+ [ Cmdlet ( VerbsCommon . Remove , "AzureRmSiteRecoveryProtectionContainerMapping" , DefaultParameterSetName = ASRParameterSets . ByObject , SupportsShouldProcess = true ) ]
27
27
[ OutputType ( typeof ( ASRJob ) ) ]
28
28
public class RemoveAzureRmSiteRecoveryProtectionContainerMapping : SiteRecoveryCmdletBase
29
29
{
@@ -52,39 +52,42 @@ public override void ExecuteSiteRecoveryCmdlet()
52
52
{
53
53
base . ExecuteSiteRecoveryCmdlet ( ) ;
54
54
55
- LongRunningOperationResponse response = null ;
56
-
57
- if ( ! this . Force . IsPresent )
55
+ if ( ShouldProcess ( this . ProtectionContainerMapping . Name , VerbsCommon . Remove ) )
58
56
{
59
- RemoveProtectionContainerMappingInputProperties inputProperties = new RemoveProtectionContainerMappingInputProperties ( )
60
- {
61
- ProviderSpecificInput = new ReplicationProviderContainerUnmappingInput ( )
62
- } ;
57
+ LongRunningOperationResponse response = null ;
63
58
64
- RemoveProtectionContainerMappingInput input = new RemoveProtectionContainerMappingInput ( )
59
+ if ( ! this . Force . IsPresent )
65
60
{
66
- Properties = inputProperties
67
- } ;
61
+ RemoveProtectionContainerMappingInputProperties inputProperties = new RemoveProtectionContainerMappingInputProperties ( )
62
+ {
63
+ ProviderSpecificInput = new ReplicationProviderContainerUnmappingInput ( )
64
+ } ;
68
65
69
- response = RecoveryServicesClient . UnConfigureProtection (
70
- Utilities . GetValueFromArmId ( this . ProtectionContainerMapping . ID , ARMResourceTypeConstants . ReplicationFabrics ) ,
71
- Utilities . GetValueFromArmId ( this . ProtectionContainerMapping . ID , ARMResourceTypeConstants . ReplicationProtectionContainers ) ,
72
- this . ProtectionContainerMapping . Name ,
73
- input ) ;
74
- }
75
- else
76
- {
77
- response = RecoveryServicesClient . PurgeCloudMapping (
78
- Utilities . GetValueFromArmId ( this . ProtectionContainerMapping . ID , ARMResourceTypeConstants . ReplicationFabrics ) ,
79
- Utilities . GetValueFromArmId ( this . ProtectionContainerMapping . ID , ARMResourceTypeConstants . ReplicationProtectionContainers ) ,
80
- this . ProtectionContainerMapping . Name ) ;
81
- }
66
+ RemoveProtectionContainerMappingInput input = new RemoveProtectionContainerMappingInput ( )
67
+ {
68
+ Properties = inputProperties
69
+ } ;
70
+
71
+ response = RecoveryServicesClient . UnConfigureProtection (
72
+ Utilities . GetValueFromArmId ( this . ProtectionContainerMapping . ID , ARMResourceTypeConstants . ReplicationFabrics ) ,
73
+ Utilities . GetValueFromArmId ( this . ProtectionContainerMapping . ID , ARMResourceTypeConstants . ReplicationProtectionContainers ) ,
74
+ this . ProtectionContainerMapping . Name ,
75
+ input ) ;
76
+ }
77
+ else
78
+ {
79
+ response = RecoveryServicesClient . PurgeCloudMapping (
80
+ Utilities . GetValueFromArmId ( this . ProtectionContainerMapping . ID , ARMResourceTypeConstants . ReplicationFabrics ) ,
81
+ Utilities . GetValueFromArmId ( this . ProtectionContainerMapping . ID , ARMResourceTypeConstants . ReplicationProtectionContainers ) ,
82
+ this . ProtectionContainerMapping . Name ) ;
83
+ }
82
84
83
- JobResponse jobResponse =
84
- RecoveryServicesClient
85
- . GetAzureSiteRecoveryJobDetails ( PSRecoveryServicesClient . GetJobIdFromReponseLocation ( response . Location ) ) ;
85
+ JobResponse jobResponse =
86
+ RecoveryServicesClient
87
+ . GetAzureSiteRecoveryJobDetails ( PSRecoveryServicesClient . GetJobIdFromReponseLocation ( response . Location ) ) ;
86
88
87
- this . WriteObject ( new ASRJob ( jobResponse . Job ) ) ;
89
+ this . WriteObject ( new ASRJob ( jobResponse . Job ) ) ;
90
+ }
88
91
}
89
92
}
90
93
}
0 commit comments