Skip to content

Instantly share code, notes, and snippets.

@isjwuk
Last active August 22, 2022 19:16
Show Gist options
  • Save isjwuk/b4d3647cfafcf3011cd1aac332d2d909 to your computer and use it in GitHub Desktop.
Save isjwuk/b4d3647cfafcf3011cd1aac332d2d909 to your computer and use it in GitHub Desktop.
Return a List of Azure VMs not backed up by Recovery Services Vaults
#Return a List of Azure VMs (in the current context) which are not backed up by Recovery Services Vaults
$BackupStatus=@()
$BackupStatus=foreach ($VM in Get-AzVM) { $VM | Select-Object Name, ResourceGroupName, @{Name="BackedUp";Expression={(Get-AzRecoveryServicesBackupStatus -Name $VM.Name -ResourceGroupName $VM.ResourceGroupName -Type AzureVM).BackedUp }}}
$BackupStatus | Where {$_.BackedUp -eq $false} | Select Name, ResourceGroupName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment