How to get unallocated data disks details using powershell Get-WmiObject in Azure

Praveen Mittapalli 36 Reputation points
2020-10-28T14:00:55.437+00:00

How to get unallocatted disks using powershell Get-WmiObject in Azure

summary:
get the list of disks that are attached to VM, but not configured in disk management? Ie. Disk volumes are not created but the disk is attached on the VMs.

Please help me on this.

Thanks in advance.

Regards,
Praveen Mittapalli
9160619064

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,784 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Leo Visser 91 Reputation points MVP
    2020-10-29T00:47:29.91+00:00

    Here is an article from microsoft on how to find and delete them:
    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/find-unattached-disks

    And if you are using
    Get-AzDisk | Where-Object {$_.ManagedBy -eq $null}

    you should get a list of all unassigned disks in azure. Or use the script provided in the first part of the help article and keep the delete variable on 0, it will then output the id's of the disks no assigned too.

    1 person found this answer helpful.

  2. whoward-msft 2,766 Reputation points
    2020-10-30T00:33:15.55+00:00

    Hi @Praveen Mittapalli ,

    To get an attached but unallocated disk your going to look for disks where the PartitionStyle is 'RAW'. To do this on the at Windows OS level you should run Get-Disk | Where-Object PartitionStyle –Eq 'RAW' in Powershell which will get you all of your unallocated disks attached at the Windows OS Level but are not allocated. If this helps please mark the answer as accepted to help others with similar questions.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.