-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-AzureRMVMOSType.ps1
47 lines (37 loc) · 1.38 KB
/
Get-AzureRMVMOSType.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<#
.SYNOPSIS
Returns OS type of the Azure RM VM
.DESCRIPTION
This utility runbook determines the OS type of the Azure RM VM (Windows/Linux etc.) and returns the value back to the caller
.PARAMETER ResourceGroupName
Name of the resource group where the VM is located.
.PARAMETER VMName
Name of the VM that you want to connect to
.EXAMPLE
CheckAzureRMVMOSType -ResourceGroupName "RG1" -VMName "VM01"
.Notes
Author: Arjun Bahree
E-mail: [email protected]
Creation Date: 13/Dec/2017
Last Revision Date: 13/Dec/2017
Version: 1.0
Development Environment: Azure Automation Runbook Editor and VS Code IDE
PS Version: 5.1
Platform: Windows
#>
param(
[Parameter(Mandatory=$true)]
[String]$ResourceGroupName,
[Parameter(Mandatory=$true)]
[String]$VMName
)
if (!(Get-AzureRmContext).Account){
Write-Error "You need to be logged into your Azure Subscription using PowerShell cmdlet 'Login-AzureRmAccount' with a valid Azure Organization Id (and not @outlook.com or any other Microsoft Live Id) having required permissions to the Azure Automation Account and Resource Group"
return
}
$vm = Get-AzureRmVM -ResourceGroupName $ResourceGroupName -Name $VMName
If ($vm)
{
# Return OS Type of the VM
return $vm.StorageProfile.OsDisk.OsType.ToString()
}