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 }
asked Jan 5, 2023 at 1:09

1 Answer 1

1

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
answered Jan 5, 2023 at 2:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.