List Azure Windows VMs Only With PowerShell

This Microsoft Azure PowerShell blog post will show how to List Azure Windows VMs Only With PowerShell.

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.

List Azure Windows VMs Only With PowerShell

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

Leave a Comment

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