/// <summary>
        /// Creates and returns <see cref="AutoBackupSettings"/> object.
        /// </summary>
        protected override void ProcessRecord()
        {
            AutoBackupSettings autoBackupSettings = new AutoBackupSettings();

            autoBackupSettings.Enable           = (Enable.IsPresent) ? Enable.ToBool() : false;
            autoBackupSettings.EnableEncryption = (EnableEncryption.IsPresent) ? EnableEncryption.ToBool() : false;
            autoBackupSettings.RetentionPeriod  = RetentionPeriodInDays;

            switch (ParameterSetName)
            {
            case StorageContextParamSetName:
                autoBackupSettings.StorageUrl       = StorageContext.BlobEndPoint;
                autoBackupSettings.StorageAccessKey = this.GetStorageKey();
                break;

            case StorageUriParamSetName:
                autoBackupSettings.StorageUrl       = (StorageUri == null)? null: StorageUri.ToString();
                autoBackupSettings.StorageAccessKey = (StorageKey == null)? null: SecureStringHelper.ConvertToUnsecureString(StorageKey);
                break;
            }

            // Check if certificate password was set
            autoBackupSettings.Password = (CertificatePassword == null) ? null : SecureStringHelper.ConvertToUnsecureString(CertificatePassword);

            WriteObject(autoBackupSettings);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates and returns <see cref="AutoBackupSettings"/> object.
        /// </summary>
        protected override void ProcessRecord()
        {
            AutoBackupSettings autoBackupSettings = new AutoBackupSettings();

            autoBackupSettings.Enable           = (Enable.IsPresent) ? Enable.ToBool() : false;
            autoBackupSettings.EnableEncryption = (EnableEncryption.IsPresent) ? EnableEncryption.ToBool() : false;
            autoBackupSettings.RetentionPeriod  = RetentionPeriodInDays;

            switch (ParameterSetName)
            {
            case StorageContextParamSetName:
                autoBackupSettings.StorageUrl       = StorageContext.BlobEndPoint;
                autoBackupSettings.StorageAccessKey = this.GetStorageKey();
                break;

            case StorageUriParamSetName:
                autoBackupSettings.StorageUrl       = (StorageUri == null)? null: StorageUri.ToString();
                autoBackupSettings.StorageAccessKey = (StorageKey == null)? null: SecureStringHelper.ConvertToUnsecureString(StorageKey);
                break;
            }

            // Check if certificate password was set
            autoBackupSettings.Password = (CertificatePassword == null) ? null : SecureStringHelper.ConvertToUnsecureString(CertificatePassword);

            autoBackupSettings.BackupSystemDbs    = BackupSystemDbs.IsPresent ? BackupSystemDbs.ToBool() : false;
            autoBackupSettings.BackupScheduleType = BackupScheduleType;

            // Set other Backup schedule settings only if BackUpSchedule type is Manual.
            if (!string.IsNullOrEmpty(BackupScheduleType) && string.Equals(BackupScheduleType, BackupScheduleManualType, StringComparison.InvariantCultureIgnoreCase))
            {
                ValidateBackupScheduleSettings();

                autoBackupSettings.FullBackupFrequency   = FullBackupFrequency;
                autoBackupSettings.FullBackupStartTime   = FullBackupStartHour;
                autoBackupSettings.FullBackupWindowHours = FullBackupWindowInHours;
                autoBackupSettings.LogBackupFrequency    = LogBackupFrequencyInMinutes;
            }

            WriteObject(autoBackupSettings);
        }