All scripts
Azure AI 333
Get-AzureVMBackupStatusReport
Reports whether every Azure VM is actually included in a backup policy, and the result of its most recent backup job, since a VM missing from a policy is easy to overlook until you need it.
Get-AzureVMBackupStatusReport.ps1
<#
.SYNOPSIS
Reports backup coverage and last job status for all Azure VMs.
.DESCRIPTION
Cross references every VM in the subscription against Recovery
Services vault backup items, flagging any VM with no backup
configured, and reports the most recent backup job status for VMs
that are covered.
.EXAMPLE
.\Get-AzureVMBackupStatusReport.ps1
.NOTES
Requires the Az.Compute and Az.RecoveryServices modules and an
active Connect-AzAccount session.
.AUTHOR
Shehryar Hassan
#>
$vms = Get-AzVM
$vaults = Get-AzRecoveryServicesVault
$backedUpVmIds = foreach ($vault in $vaults) {
Set-AzRecoveryServicesVaultContext -Vault $vault
(Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM).VirtualMachineId
}
$report = $vms | ForEach-Object {
[pscustomobject]@{
VMName = $_.Name
HasBackup = $_.Id -in $backedUpVmIds
}
}
$report | Where-Object { -not $_.HasBackup } | Format-Table -AutoSize
Write-Warning "$(($report | Where-Object { -not $_.HasBackup }).Count) of $($vms.Count) VM(s) have no backup configured."
Read it before you run it, and test in a safe tenant first.