- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to retrieve the OS of the Azure VM using Azure CLI in PowerShell?
To retrieve the Azure VM OS using Azure CLI, we can use the “az vm” command but before that, need to make sure that you are connected to the Azure cloud and the subscription.
PS C:\> az vm show -n VMName -g VMRG --query "[storageProfile.imageReference.offer]" -otsv
OR
PS C:\> az vm show -n VMName -g VMRG --query storageProfile.imageReference.offer - otsv
Output
WindowsServer
To get the OS SKU or the operating system version, you can use,
PS C:\> az vm show -n VMName -g VMRG --query "[storageProfile.imageReference.sku]" -otsv
Output
2016-Datacenter
You can also use the below command to get the OS of the VM without providing the resource group name.
PS C:\> az vm list --query "[?name==VMName].{os:storageProfile.imageReference.offer}" -otsv
To get the OS version or SKU,
PS C:\> az vm list --query "[?name==VMName].{os:storageProfile.imageReference.sku}" -otsv
To combine all the outputs in the table format,
az vm list --query "[].{vmName:name, ResourceGroup:resourceGroup, os:storageProfile.imageReference.offer, version:storageProfile.imageReference.sku}" - otable
- Related Articles
- How to retrieve the Azure VM nic name using Azure CLI in PowerShell?
- How to retrieve the OS caching setting of Azure VM using Azure\nCLI in PowerShell?
- How to deallocate the Azure VM using Azure CLI in PowerShell?
- How to start the Azure VM using Azure CLI in PowerShell?
- How to stop the Azure VM using Azure CLI in PowerShell?
- How to restart the Azure VM using Azure CLI in PowerShell?
- How to resize the Azure VM using Azure CLI in PowerShell?
- How to get the Azure VM Size using Azure CLI in PowerShell?
- How to get the Azure VM username using Azure CLI in PowerShell?
- How to list the azure VM extensions using Azure CLI in PowerShell?
- How to get the location of the Azure VM using Azure CLI in PowerShell?
- How to get the available azure VM size using Azure CLI in PowerShell?
- How to open port for the Azure VM using Azure CLI in PowerShell?
- How to get all the available azure VM images using Azure CLI in PowerShell?
- How to retrieve the Azure VM resource group using PowerShell?

Advertisements