Export a list of XenDesktop VDIs to CSV with PowerShell

Export a list of XenDesktop VDIs to CSV with PowerShell
Have you ever wanted to export a list of XenDesktop VDIs to CSV with PowerShell?

I wanted to do this just recently but had trouble finding the relevant info, so hopefully this helps someone out.

Make sure you have the Citrix Powershell SDK installed. The PowerShell SDK is installed by default on XenDesktop 5 Controllers.

From the Citrix Knowledge Center article Getting Started with PowerShell in XenDesktop 5

Begin a PowerShell session by clicking the blue icon on the taskbar or browsing to Start > All Programs > Accessories > Windows PowerShell > Windows PowerShell (On 64-bit systems, this starts the 64-bit version. Either the 32-bit or 64-bit versions will work fine though.)

Type Asnp Citrix.* and press Enter. This loads the Citrix-specific PowerShell modules. (Asnp is short for Add-PSSnapin).
Run the Citrix cmdlets.
To list all of the ones available, run Get-Command –Module Citrix.*

Help might be obtained on any cmdlet by running Get-Help <cmdlet> such as Get-Help Get-BrokerDesktop (additional details might be obtained by adding on the –examples, -detailed, or –full switches)

The command you want to export a list of XenDesktop VDIs to CSV with PowerShell is as follows:

Get-BrokerDesktop -AdminAddress servername -MaxRecordCount 1000 -DesktopKind Private | sort desktopgroupname | export-csv “outputfile.csv

Items in bold can be changed to required values.

Hope this saves you some time searching!

Author: Mike

Mike Streetz is a Citrix Consultant who works with everyone from small businesses to large enterprises to help their users get work done via Citrix Virtual Apps and Desktops. He has been working in the Citrix space for over 10 years. Mike knows that your users don’t want long logon times, don’t want long waits for files and don’t enjoy when “Citrix is slow”. His job is to help you get the most out of your Citrix environment. Mike has worked with clients to optimize user experience by using tools such as FSLogix alongside Citrix ADC with Global Server Load Balancing to point users to the fastest site to serve their needs. Mike is a Citrix Technology Advocate, CUGC Leader of the Los Angeles chapter, Citrix Certified Professional in Citrix Cloud, Virtual Apps and Desktops and Citrix ADC and holds the Azure Administrator Associate certification. He has previously spoken at the Ruxcon security conference in Australia.