0

We have about 30 SQL instances being backed up by Azure Backup. I have the needed PowerShell commands to set the AutoProtect policy, but there doesn't seem to be a command to get the AutoProtect status or policy. Anyone got any ideas how to get this via PowerShell?

In case anyone is interested, here is the code to set the policy:

$vault = Get-AzRecoveryServicesVault -ResourceGroupName "MyResourceGroupName" -Name "MyRSVname"
$pol = Get-AzRecoveryServicesBackupProtectionPolicy -Name "MyPolicyName"
$sqlinstances = Get-AzRecoveryServicesBackupProtectableItem -workloadType MSSQL -ItemType SQLInstance -VaultId $vault.ID

foreach ($SQLInstance in $sqlinstances) { Enable-AzRecoveryServicesBackupAutoProtection -InputItem $SQLInstance -BackupManagementType AzureWorkload -WorkloadType MSSQL -Policy $pol -VaultId $vault.ID }

1 Answer 1

0

Ok, figured it out:

$vault = Get-AzRecoveryServicesVault -ResourceGroupName "MyResourceGroupName" -Name "MyRSVname"
$pol = Get-AzRecoveryServicesBackupProtectionPolicy -Name "MyPolicyName"
$sqlinstances = Get-AzRecoveryServicesBackupProtectableItem -workloadType MSSQL -ItemType SQLInstance -VaultId $vault.ID
$sqlinstances | Select ServerName, IsAutoProtectable, IsAutoProtected, AutoProtectionPolicy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.