Get old Azure Disk Snapshots with PowerShell

Taking a snapshot of a disk is often a useful precaution before making a big change to an Azure VM. However, it’s easy for them to get forgotten about and remain on your account eating up budget. This PowerShell snippet will find old Snapshots in your subscription.

1Get-AzSnapshot | 
2  Where-Object {$_.TimeCreated -lt (Get-Date).AddDays(-30)} | 
3  Select-Object name, TimeCreated, ResourceGroupName

Sample Output

1Name                                            TimeCreated         ResourceGroupName
2----                                            -----------         -----------------
3VMNumber1-Snapshot1                             01/09/2021 08:40:21 ResourceGroupA
4VMNumber1-Snapshot2                             01/10/2020 08:10:55 ResourceGroupA
5VMNumber2-Snapshot1                             22/09/2020 10:51:29 ResourceGroupB