Personal Virtual Desktop Collection: User Assignment

Using Windows Server 2012 Remote Desktop Services, I have a 'Personal Virtual Desktop Collection' with automatic user assignment enabled.

According to Microsoft "Personal virtual desktops are permanently assigned to a user account and the user logs on to the same virtual desktop each time."

Is there a way either through the Server Manager UI or PowerShell to determine which user has been assigned to which VM?

The only way I have found so far is to query the 'Remote Desktop Users' group on each VM in the collection, however that requires each VM to be powered on. There must be a better way.


Solution 1:

Two ways.

PowerShell Module:

From a Windows 8/Windows Server 2012 machine in PowerShell you should be able to use the Get-RDPersonalVirtualDesktopAssignment command. You can specify a connection broker to connect to with -ConnectionBroker <String>, or query by collection and user.

Active Directory:

You may be able to find the information in Active Directory if Windows Server 2012 maintains the same schema as in 2008 R2, you may be able to find it by querying users for the msTSPrimaryDesktop attribute. To search by attribute in PowerShell, on Windows 7/2008 R2 and previous versions you may need to first run Import-Module ActiveDirectory, and then execute the command:

Get-ADUser -Properties msTSPrimaryDesktop -Filter { msTSPrimaryDesktop -like "*" }

The msTSPrimaryDesktop property is used in VDI in Windows Server 2008 R2 at least, and is also accessible on certain machines via Active Directory Users and Computers (dsa.msc). I am not sure if Windows Server 2012 uses this property as a user's primary desktop may be relative to a particular collection, not global as per 2008 R2.