Tools: Stop Burning Money: How to Find Orphaned Azure Disks with PowerShell

Tools: Stop Burning Money: How to Find Orphaned Azure Disks with PowerShell

Source: Dev.to

The Invisible Cost of the Cloud ## The Solution One of the most common "silent killers" in Azure billing is the Orphaned Managed Disk. When you delete a Virtual Machine in Azure, the default behavior often leaves the OS and Data disks behind. These disks sit in your Resource Group, unattached, doing nothing—but you are still paying for them every single month. As a Cloud Engineer, I wrote a quick PowerShell script to audit an entire tenant for these "zombie" resources. We can use the Get-AzDisk cmdlet to inspect the ManagedBy property. If this property is null, the disk is not attached to any compute resource. Here is the core logic: Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK: powershell $disks = Get-AzDisk foreach ($disk in $disks) { if ($null -eq $disk.ManagedBy) { Write-Host "Orphan Found: $($disk.Name)" } } Get the Full Script I have published a robust version of this tool on my https://github.com/LordTalyn1984/LordTalyn1984. It scans all subscriptions and generates a CSV report for your finance team. View the Code on GitHub Why This Matters For a standard Premium SSD (P30), you could be wasting over $130/month per disk. In a large environment, I've seen this script uncover thousands of dollars in wasted spend in under 5 minutes. Gavin Dobbs is a Cloud Engineer specializing in Azure Governance and Automation. Connect with me on https://www.linkedin.com/in/gavin-dobbs-texas/. Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: powershell $disks = Get-AzDisk foreach ($disk in $disks) { if ($null -eq $disk.ManagedBy) { Write-Host "Orphan Found: $($disk.Name)" } } Get the Full Script I have published a robust version of this tool on my https://github.com/LordTalyn1984/LordTalyn1984. It scans all subscriptions and generates a CSV report for your finance team. View the Code on GitHub Why This Matters For a standard Premium SSD (P30), you could be wasting over $130/month per disk. In a large environment, I've seen this script uncover thousands of dollars in wasted spend in under 5 minutes. Gavin Dobbs is a Cloud Engineer specializing in Azure Governance and Automation. Connect with me on https://www.linkedin.com/in/gavin-dobbs-texas/. CODE_BLOCK: powershell $disks = Get-AzDisk foreach ($disk in $disks) { if ($null -eq $disk.ManagedBy) { Write-Host "Orphan Found: $($disk.Name)" } } Get the Full Script I have published a robust version of this tool on my https://github.com/LordTalyn1984/LordTalyn1984. It scans all subscriptions and generates a CSV report for your finance team. View the Code on GitHub Why This Matters For a standard Premium SSD (P30), you could be wasting over $130/month per disk. In a large environment, I've seen this script uncover thousands of dollars in wasted spend in under 5 minutes. Gavin Dobbs is a Cloud Engineer specializing in Azure Governance and Automation. Connect with me on https://www.linkedin.com/in/gavin-dobbs-texas/.