Example #1
0
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                base.ExecuteCmdlet();

                BackupManagementType?backupManagementTypeNullable = null;
                BackupManagementType backupManagementType;
                if (BackupManagementType != null)
                {
                    Enum.TryParse <BackupManagementType>(BackupManagementType, out backupManagementType);
                    backupManagementTypeNullable = backupManagementType;
                }

                PsBackupProviderManager providerManager =
                    new PsBackupProviderManager(new Dictionary <System.Enum, object>()
                {
                    { ContainerParams.ContainerType, ContainerType },
                    { ContainerParams.BackupManagementType, backupManagementTypeNullable },
                    { ContainerParams.Name, Name },
                    { ContainerParams.FriendlyName, FriendlyName },
                    { ContainerParams.ResourceGroupName, ResourceGroupName },
                    { ContainerParams.Status, Status },
                }, ServiceClientAdapter);

                IPsBackupProvider psBackupProvider =
                    providerManager.GetProviderInstance(ContainerType, backupManagementTypeNullable);
                var containerModels = psBackupProvider.ListProtectionContainers();
                WriteObject(containerModels, enumerateCollection: true);
            });
        }
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                base.ExecuteCmdlet();

                BackupManagementType?backupManagementTypeNullable = null;
                BackupManagementType backupManagementType;
                if (BackupManagementType != null)
                {
                    Enum.TryParse(BackupManagementType, out backupManagementType);
                    backupManagementTypeNullable = backupManagementType;
                }

                // Forcing this cmdlet to return only Registered containers for now.
                // Once we support containers returning other status types, one can undo this behavior.
                Status = ContainerRegistrationStatus.Registered;

                PsBackupProviderManager providerManager =
                    new PsBackupProviderManager(new Dictionary <Enum, object>()
                {
                    { ContainerParams.ContainerType, ContainerType },
                    { ContainerParams.BackupManagementType, backupManagementTypeNullable },
                    { ContainerParams.Name, Name },
                    { ContainerParams.FriendlyName, FriendlyName },
                    { ContainerParams.ResourceGroupName, ResourceGroupName },
                    { ContainerParams.Status, Status },
                }, ServiceClientAdapter);

                IPsBackupProvider psBackupProvider =
                    providerManager.GetProviderInstance(ContainerType, backupManagementTypeNullable);
                var containerModels = psBackupProvider.ListProtectionContainers();
                WriteObject(containerModels, enumerateCollection: true);
            });
        }