@@ -54,7 +54,6 @@ public override void ExecuteCmdlet()
54
54
base . ExecuteCmdlet ( ) ;
55
55
56
56
List < AzureBackupContainer > containers = new List < AzureBackupContainer > ( ) ;
57
- bool uniqueContainer = false ;
58
57
59
58
switch ( Type )
60
59
{
@@ -63,18 +62,15 @@ public override void ExecuteCmdlet()
63
62
containers . AddRange ( GetMachineContainers ( ) ) ;
64
63
break ;
65
64
case AzureBackupContainerType . AzureVM :
66
- uniqueContainer = GetManagedContainers ( containers ) ;
65
+ containers . AddRange ( GetManagedContainers ( ) ) ;
67
66
break ;
68
67
default :
69
68
break ;
70
69
}
71
70
72
- if ( uniqueContainer )
71
+ if ( containers . Count == 1 )
73
72
{
74
- if ( containers . Any ( ) )
75
- {
76
- WriteObject ( containers . First ( ) ) ;
77
- }
73
+ WriteObject ( containers . First ( ) ) ;
78
74
}
79
75
else
80
76
{
@@ -101,8 +97,10 @@ private List<AzureBackupContainer> GetMachineContainers()
101
97
} ) . Where ( container => container . ContainerType == Type . ToString ( ) ) . ToList ( ) ;
102
98
}
103
99
104
- private bool GetManagedContainers ( List < AzureBackupContainer > managedContainers )
100
+ private List < AzureBackupContainer > GetManagedContainers ( )
105
101
{
102
+ List < AzureBackupContainer > managedContainers = new List < AzureBackupContainer > ( ) ;
103
+
106
104
ContainerQueryParameters parameters = new ContainerQueryParameters ( ) ;
107
105
parameters . ContainerType = ManagedContainerType . IaasVM . ToString ( ) ;
108
106
parameters . FriendlyName = Name ;
@@ -134,9 +132,7 @@ private bool GetManagedContainers(List<AzureBackupContainer> managedContainers)
134
132
return new AzureBackupContainer ( Vault , container ) ;
135
133
} ) ) ;
136
134
137
- // When container resource name and container resource group name are specified, this parameter set
138
- // identifies a container uniquely. Thus, we return just one container instead of a list.
139
- return ! string . IsNullOrEmpty ( Name ) & ! string . IsNullOrEmpty ( ManagedResourceGroupName ) ;
135
+ return managedContainers ;
140
136
}
141
137
}
142
138
}
0 commit comments