Azure VM status permissions

Glenn Maxwell 10,106 Reputation points
2022-06-21T18:40:25.397+00:00

Hi All

i have a resource groups lets say resourcegroup1 it has Azure Virtual Desktops in it and my requirement is to know what is the status of the Virtual Machine(Azure virtual desktop VMs) in this resource group i.e it is running or stopped state and i want to fetch this using PowerShell. so i have created a custom role and provide the below access, using this permission i am not getting the status of the VM but i can get the VM name. experts guide me what permissions are required for VM status

Microsoft.Compute/virtualMachines/read

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,085 questions
Azure Role-based access control
Azure Role-based access control
An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
660 questions
Azure Virtual Desktop
Azure Virtual Desktop
A Microsoft desktop and app virtualization service that runs on Azure. Previously known as Windows Virtual Desktop.
1,358 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,389 questions
0 comments No comments
{count} votes

Accepted answer
  1. Manu Philip 16,966 Reputation points MVP
    2022-06-22T14:04:30.55+00:00

    I found a way to get the VM status as follows: Check, if this helps !

    Find WvdSessionHost Name as below:

    Get-AzWvdSessionHost "ResourceGroup01" -HostPoolName "MYPOOL1" | Select Name  
    

    213931-image.png

    Get VM status. Note that, Name to be added as vd-0 from VD/vd-0

    Get-AzVM -ResourceGroupName "ResourceGroup01" -name vd-0 -Status  
    

    This will show the full status details. At the end you can also see the running status

    213922-image.png

    ----------

    --please don't forget to upvote and Accept as answer if the reply is helpful--


2 additional answers

Sort by: Most helpful
  1. Manu Philip 16,966 Reputation points MVP
    2022-06-21T19:03:43.15+00:00

    It sounds like you need to assign a bit different permissions to read the running status of Virtual Desktops : rbac

    ----------

    --please don't forget to upvote and Accept as answer if the reply is helpful--


  2. Manu Philip 16,966 Reputation points MVP
    2022-06-21T20:42:36.413+00:00

    If the above commands are not helping, we need to try with az cli command for getting more details of Azure Virtual Desktop machines deployed.
    Make sure that you have installed the required PowerShell modules: Install-Module -Name Az.DesktopVirtualization

    Get the host pool details with the list of WVD host pool hosted in the WVD environment. : AzWVDHostPool | Select-Object *
    Get-AzWVDSessionHost to get a list of session hosts attached to each host pool

    Get-AzWvdSessionHost -ResourceGroupName $ResGroup -HostPoolName $PoolName | Select-Object *  
    

    Hope, the above details will help to frame the required command you are looking for

    0 comments No comments