- 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 Operating system of the Azure VM using PowerShell?
To retrieve the OS details of the Azure VM, we need to use the Get-AzVM command.
Example
Get-AzVM -VMName TestMachine2k16
When you run the above command, it retrieves the VM TestMachine2k16 information and there is an OSType property which shows that if the VM’s OS is Linux or Windows, or any other type.
But when you select the OSType, you won’t get anything. See below.
Example
PS C:\> Get-AzVM -VMName TestMachine2k16 | Select OStype OStype ------
Because this property is a part of another property and hence can’t be accessed directly. When you expose the full properties of the VM, you will get the StorageProfile, which contains the OS information.
Example
PS C:\> $vm = Get-AzVM -VMName TestMachine2k16 PS C:\> $vm | fl *
Output
Use the below command,
Example
PS C:\> $vm.StorageProfile.ImageReference Publisher : MicrosoftWindowsServer Offer : WindowsServer Sku : 2016-Datacenter Version : latest ExactVersion : 14393.4225.2102030345 Id :
So here we got both the Server Edition and the version.
Output
PS C:\> $osver = $vm.StorageProfile.ImageReference.Offer + " $($vm.StorageProfile.ImageReference.Sku)" PS C:\> $osver WindowsServer 2016-Datacenter
- Related Articles
- How to retrieve the Azure VM resource group using PowerShell?
- How to retrieve the Azure VM Subscription Name using PowerShell?
- How to retrieve the Azure VM NIC name using PowerShell?
- How to retrieve the Azure VM vNet name using PowerShell?
- How to retrieve the Azure VM deallocated date using PowerShell?
- How to retrieve the OS of the Azure VM using Azure CLI in PowerShell?
- 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 retrieve the Azure VM RAM and CPU size using PowerShell?
- How to retrieve the Azure VM network security group (NSG) using 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?

Advertisements