0

Which Azure Disk Is Not Attached

Over time a typical Azure subscription will create, delete and manage multiple virtual machines.  When removing an Azure VM there is the option to retain the disk.

In a large environment with lots of disks and VMs, how can we easily see what disks are not currently in use?

 

Azure Portal

The portal can show the disks that are attached and not attached.

Azure - Using Portal To See Which Disks Are Not Attached or In Use

This is good for a few disks, though if there are many then PowerShell may be preferred.

 

PowerShell

Azure PowerShell offers a nice easy way to see this information, and is available here with documentation.

Connect into your subscription using Azure PowerShell, and once you have selected the relevant subscription issue the following command:

Get-AzureDisk | Where-Object {$_.AttachedTo -eq $Null}

 

The below image highlights the AttachedTo field, and the sensitive data in my subscription has been redacted.

Azure - Using PowerShell To See Which Disks Are Not Attached or In Use

This will check for all disks that are not currently attached to a VM.

Cheers,

Rhoderick

Rhoderick Milne [MSFT]

Leave a Reply

Your email address will not be published. Required fields are marked *