{"id":4131,"date":"2016-02-04T16:16:35","date_gmt":"2016-02-05T00:16:35","guid":{"rendered":"http:\/\/www.atumvirt.com\/?p=4131"},"modified":"2016-02-04T16:16:35","modified_gmt":"2016-02-05T00:16:35","slug":"adding-rds-assigned-virtual-desktop-user-to-scvmm","status":"publish","type":"post","link":"https:\/\/avtempwp.azurewebsites.net\/2016\/02\/adding-rds-assigned-virtual-desktop-user-to-scvmm\/","title":{"rendered":"Adding RDS Assigned Virtual Desktop User to SCVMM"},"content":{"rendered":"
When working with RDS VDI scenarios using VMM, it may be helpful to have a view of which users are assigned to persistent desktops.\u00a0 Using the extensible power of Virtual Machine manager, you can easily provide this information to all of your virtual machines.\u00a0 The script below can be run on a schedule to keep this data in sync or as part of an automation workflow.<\/p>\n
First, you must prepare the property you will use.<\/p>\n
Import-Module VirtualMachineManager\n\nNew-SCCustomProperty -Name \"RDUser\" -AddMember @(\"VM\")<\/pre>\nOnce this has been done, schedule\/run the following script manually<\/p>\n
Import-Module RemoteDesktop,VirtualMachineManager\n$broker= \"RDBroker.Contoso.com\"\n$VMMServer=\"SCVMM.Contoso.com\"\n$Deployment = Get-RDRemoteDesktop -connectionBroker $broker\n$RDUserProperty=Get-SCCustomProperty -Name \"RDUser\"\u00a0 #We need an object that represents the property \"RDUser\"\n\n#Get the RD Persistent Assignments\n$RDPVDA= Get-RDPersonalVirtualDesktopAssignment -collectionName $Deployment.CollectionName -connectionBroker $broker\n\nforeach ($entry in $RDPVDA)\n{\n#First we get the VM we want to work with, set variable to null prior to starting work to avoid working on old resources\n$vm = $null\n$vm = get-VM $entry.VirtualDesktopName -VMMServer $VMMServer\n#Now we set it!\nSet-SCCustomPropertyValue -inputobject $vm -customproperty $RDUserProperty -value $entry.user\n}\n\n <\/pre>\nOnce completed, you\u2019ll be able to customize your view to see this property (right click the column headers to add another)<\/p>\n