Azure Microsoft Powershell

Azure PowerShell to find out Disk size

PowerShell to list Azure Data disks that are a certain size.

As I mentioned in my last post, I was tasked with decreasing the disk size on some disks on Azure. I did not want to go to Azure Portal and then look for the disks that fit the criteria manually. PowerShell came into rescue!

#If this is the first time you are using the Az module, 
#you will probably need to install the module first.  #Afterward, use Connect-AzAccount to sign in with your Azure account.


#I am already in the correct subscription.  
#You may need to use the Set-AzContext cmdlet to 
#change your subscription before you can find the correct disks.  
#The script below will look for any disk that contains "SQL" as a wild card in the name. 
#Specifically, I am looking for disks that are in the p70 tier (p70 has IOPS read write of 18,000)

Get-AzDisk -DiskName "*SQL*" | Where-Object {$_.DiskIOPSReadWrite -eq "18000"} | Select Name, DiskSizeGB, DiskIOPSReadWrite | Sort Name

#You can also pipe the result with a Export-CSV cmdlet to send the output to a CSV file

I removed the name for the disks for privacy purpose. You should see the name of your disks running the script above.

Alternately, if you are only looking for a count of all the disks in a specific tier, you can utilize the Measure-Object cmdlet.

Get-AzDisk -DiskName "*SQL*" | Where-Object {$_.DiskIOPSReadWrite -eq "18000"} | Measure-Object  

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s