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!