List Azure Windows VMs Only With PowerShell

This Microsoft Azure PowerShell blog post will show how to use Azure PowerShell to list all the Windows-based virtual machines.

When running Windows-based virtual machines in Azure, there are cases where you will need to run scripts or reports on your Windows VMs only.

You can always generate a report from the portal on the hostname of the machines, but you can also use PowerShell to do it and then pipe the hosts to a script.

The PowerShell method is more effective because it shows results in real time.

PowerShell Code

The following code will use the Azure PowerShell module (AZ) to list all the Windows virtual machines in your subscription.

$vmList = Get-AzVM | Where-Object { $_.StorageProfile.OsDisk.OsType -eq "Windows" } -Verbose


Posted

in

,

by

Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.