14
14
15
15
function Test-GetItemScenario
16
16
{
17
+ # 1. Get the vault
17
18
$vault = Get-AzureRmRecoveryServicesVault - ResourceGroupName " RsvTestRG" - Name " PsTestRsVault" ;
19
+
20
+ # 2. Set the vault context
18
21
Set-AzureRmRecoveryServicesVaultContext - Vault $vault ;
19
22
20
- $namedContainer = Get-AzureRmRecoveryServicesBackupContainer - ContainerType " AzureVM" - Status " Registered" ;
21
- Assert-AreEqual $namedContainer [2 ].FriendlyName " mkheranirmvm1" ;
23
+ # 3. Get the container
24
+ $namedContainer = Get-AzureRmRecoveryServicesBackupContainer - ContainerType " AzureVM" - Status " Registered" - Name " mkheraniRMVM1" ;
25
+ Assert-AreEqual $namedContainer.FriendlyName " mkheraniRMVM1" ;
26
+
27
+ # VAR-1: Get all items for container
28
+ $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" ;
29
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1" ;
30
+
31
+ # VAR-2: Get items for container with friendly name filter
32
+ $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" - Name " mkheraniRMVM1" ;
33
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1" ;
34
+
35
+ # VAR-3: Get items for container with ProtectionStatus filter
36
+ $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" - ProtectionStatus " Healthy" ;
37
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1" ;
38
+
39
+ # VAR-4: Get items for container with Status filter
40
+ $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" - Status " Protected" ;
41
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1" ;
22
42
23
- $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer [2 ] - WorkloadType " AzureVM" - Name " mkheranirmvm1" ;
24
- echo $item.Name ;
43
+ # VAR-5: Get items for container with friendly name and ProtectionStatus filters
44
+ $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" - Name " mkheraniRMVM1" - ProtectionStatus " Healthy" ;
45
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1" ;
46
+
47
+ # VAR-6: Get items for container with friendly name and Status filters
48
+ $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" - Name " mkheraniRMVM1" - Status " Protected" ;
49
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1" ;
50
+
51
+ # VAR-7: Get items for container with Status and ProtectionStatus filters
52
+ $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" - Status " Protected" - ProtectionStatus " Healthy" ;
53
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1" ;
54
+
55
+ # VAR-8: Get items for container with friendly name, Status and ProtectionStatus filters
56
+ $item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" - Name " mkheraniRMVM1" - Status " Protected" - ProtectionStatus " Healthy" ;
57
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1" ;
25
58
}
26
59
27
60
function Test-EnableAzureVMProtectionScenario
@@ -87,15 +120,21 @@ function Test-RestoreAzureVMRItemScenario
87
120
88
121
function Test-BackupItemScenario
89
122
{
90
- $vault = Get-AzureRmRecoveryServicesVault - ResourceGroupName " pstestrg" - Name " pstestrsvault" ;
123
+ # 1. Get the vault
124
+ $vault = Get-AzureRmRecoveryServicesVault - ResourceGroupName " RsvTestRG" - Name " PsTestRsVault" ;
125
+
126
+ # 2. Set the vault context
91
127
Set-AzureRmRecoveryServicesVaultContext - Vault $vault ;
92
128
93
- $namedContainer = Get-AzureRmRecoveryServicesBackupContainer - ContainerType " AzureVM" - Status " Registered" - Name " pstestv2vm1" ;
94
- Assert-AreEqual $namedContainer.FriendlyName " pstestv2vm1" ;
129
+ # 3. Get the container
130
+ $namedContainer = Get-AzureRmRecoveryServicesBackupContainer - ContainerType " AzureVM" - Status " Registered" - Name " mkheraniRMVM1" ;
131
+ Assert-AreEqual $namedContainer.FriendlyName " mkheraniRMVM1" ;
95
132
133
+ # 4: Get the item
96
134
$item = Get-AzureRmRecoveryServicesBackupItem - Container $namedContainer - WorkloadType " AzureVM" ;
97
- echo $item.Name ;
135
+ Assert-AreEqual $item.Name " iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1 " ;
98
136
99
- $job = Backup-AzureRmRecoveryServicesItem - Item $item ;
137
+ # 5: Trigger backup
138
+ $job = Backup-AzureRmRecoveryServicesBackupItem - Item $item ;
100
139
Assert-NotNull $job ;
101
140
}
0 commit comments