AVD information

Roger Roger 4,951 Reputation points
2023-02-05T19:25:06.3966667+00:00

Hi All

I am using azure virtual desktop. i have a Host Pool and i want to export all AVDs information to csv file. When i go to Azure Virtual Desktop-->Host Pools-->Pool1. i can export to csv file but i want to get what SKUs they are. i don't see that information. is it possible to get that information from PowerShell.

Azure Virtual Desktop
Azure Virtual Desktop
A Microsoft desktop and app virtualization service that runs on Azure. Previously known as Windows Virtual Desktop.
1,362 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,359 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 96,036 Reputation points MVP
    2023-02-08T09:31:54.5133333+00:00

    Hi @Roger Roger ,

    please try this script. I haven't tested the assignedUser details because I have no Personal Session Hosts in my environment.

    $rg = "<your resource group name>"
    $hostPool = "<your host group name"
    $outFile = "Sample7outputAvdVMs.txt"
    $header = "Name,Status,assignedUser,subscription,resourceGroup,sku"
    Out-File -FilePath $outfile -Encoding utf8 -InputObject $header
    $output = ""
    $sessionHosts = (Get-AzWvdSessionHost -ResourceGroupName $rg -HostPoolName $hostPool) # .ResourceId
    $sessionHosts | ForEach-Object {
        $vmName = ($_.ResourceId).Split("/")[-1]
        $vmObj = (Get-AzVM -Name $vmName)
        $vmStatus = (Get-AzVM -Name $vmName -Status).PowerState
        $vmRG = $vmObj.ResourceGroupName
        $vmSubscription = $vmObj.Id.Split("/")[2]
        $vmSize = $vmObj.HardwareProfile.VmSize
        $vmAssignedUser = $_.AssignedUser
        $output = "$vmName,$vmStatus,$vmAssignedUser,$vmSubscription,$vmRG,$vmSize"
        Out-File -FilePath $outfile -Encoding utf8 -InputObject $output -Append
    }
    

    The result looks here like this (as I mentioned before I have no personal Session Hosts in my environment):

    Name,Status,assignedUser,subscription,sku
    WVD-pHost-0,VM deallocated,,<subscription id>,<name of VM Resource Group>,Standard_B2ms
    WVD-pHost-1,VM deallocated,,<subscription id>,<name of VM Resource Group>,Standard_B2ms
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards Andreas Baumgarten

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Prrudram-MSFT 21,886 Reputation points
    2023-02-06T14:08:59.2733333+00:00

    Hi @Roger Roger

    Thank you for reaching out to the Microsoft Q&A platform. Happy to answer your question.

    The SKUs aren't part of the host pool metadata, that's why you are not getting the details of SKU when you query. You would need to query the RG that contains the VM in addition to the Get-AzWVDSessionHost.

    Hope this helps!

    If this response answered your question please hit 'Accept Answer' and Upvote so that this can be beneficial to other community members.

    0 comments No comments

  2. Limitless Technology 43,926 Reputation points
    2023-02-07T16:11:49.5233333+00:00
    Hello, thanks for coming into forums. I will be more than happy to help you.
    
    You can use the following PowerShell script to export the information for your host pool:
    
    
    $outputFile = "AVDs_Information.csv"
    
    $header = "Name, Status, Assigned User, Subscription, SKU"
    $header | Out-File $outputFile
    
    $AVDs = Get-AzWvdSessionHost -ResourceGroupName "myrg" -HostPoolName "pool1"
    
    foreach ($AVD in $AVDs) {
        $Name = $AVD.Name
        $Status = $AVD.SessionHostStatus
        $AssignedUser = $AVD.AssignedUserPrincipalName
        $Subscription = $AVD.SubscriptionId
        $SKU = $AVD.Sku.Name
    
        $output = "$Name, $Status, $AssignedUser, $Subscription, $SKU"
        $output | Out-File $outputFile -Append
    }
    
    
    This script will export the information for each AVD in your host pool (pool1) to a CSV file named AVDs_Information.csv. 
    The information exported includes the: Name, Status, Assigned User, Subscription, and SKU.
    
    0 comments No comments

  3. Limitless Technology 43,926 Reputation points
    2023-02-07T16:12:21.03+00:00

    Double post

    0 comments No comments

  4. Roger Roger 4,951 Reputation points
    2023-02-07T17:07:09.24+00:00

    i have tried the script but the below output is empty

    Status

    Assigned User

    Subscription

    SKU

    0 comments No comments