需要帮助更改恢复服务保管库中每个备份策略的保留期。我们在每个保管库中有多个保管库和许多策略。因此想要编写该过程的脚本。
下面是我用来获取所有保险库中所有策略的脚本。但无法更改每个策略的保留期
$recoveryServicesVaults=Get-AzureRmRecoveryServicesVault
foreach($recoveryServicesVault in $recoveryServicesVaults)
{
Set-AzureRmRecoveryServicesVaultContext -Vault $recoveryServicesVault
$backupPolicies=Get-AzureRmRecoveryServicesBackupProtectionPolicy -
WarningAction Ignore
$backupPolicyArray=@()
foreach($backupPolicy in $backupPolicies)
{
$Info = New-Object PSObject -Property @{
PolicyName=$backupPolicy.Name
WorkloadType=$backupPolicy.WorkloadType
DailyRetentionPolicyDuration=$backupPolicy.RetentionPolicy.dailyschedule.DurationCountInDays
}
$backupPolicyArray += $Info
}
$backupPolicyArray
}