Archive for June, 2017

Citrix XenDesktop Power State Off but Registration displays Registered

Monday, June 12th, 2017

User was having issue accessing her virtual desktop. She was getting the spinning as if the machine was trying to be powered on when attempting to launch her Enterprise Static Desktop and eventually it would fail and Citrix Director was reporting timeout. I attempted the normal restart of machine and also forced reset in VMware with no success. Upon further diagnosis noted her machine was reporting that the Power State was OFF in the Citrix Studio console and yet the Registration Status was stating Registered (normally if Power State is OFF machine will be Unregistered). So upon further investigation I found the virtual machine was actually ON within VMWare host so the Power State in Citrix Studio was being incorrectly reported.

It appears something with HostMachineID wasn’t correctly updated in the SQL database, I validated this by running a few commands and then ultimately updating SQL database with correct HostMachineID. I’m providing this information in the event this happens again, I’m not sure what the root cause is other than possibly the database was synchronizing when the outage occurred Saturday night and failed back over with incorrect machineID when she attempted a connection.

Below are the steps, if there is any question if this is the issue please validate before running the final command as this can cause serious issues to other virtual desktops if wrong Ids are updated in database

1. Within Citrix Studio launch PowerShell Console and run following command:

asnp Citrix*
Get-ChildItem -Path XdHyp:\ -force -recurse | ?{ $_.IsMachine } | Out-File –Filepath c:\xdhyp.txt

2. This will give you output to c:\xdhyp.txt, review the txt and do a Find for the machine in question in our circumstance it was LABVSM007, what we are specifically looking for is the Id I’ve highlighted in yellow below. Please record this information once you’ve validated the correct Name of machine.

PSPath : Citrix.Host.Admin.V2\Citrix.Hypervisor::XDHyp:\Connections\labesx\datacenter\VDI.cluster\labvsm007.vm
PSParentPath : Citrix.Host.Admin.V2\Citrix.Hypervisor::XDHyp:\Connections\labesx\datacenter\VDI.cluster
PSChildName : labvsm007.vm
PSDrive : XDHyp
PSProvider : Citrix.Host.Admin.V2\Citrix.Hypervisor
PSIsContainer : True
AdditionalData : {[PowerState, PoweredOn], [MachineAddress,]}
FullName : labvsm007.vm
FullPath : XDHyp:\Connections\labesx\datacenter\VDI.cluster\bosvsm007.vm
Id : 4be83442-2367-690e-06ea-2543bab2afce
IsContainer : True
IsMachine : True
IsSnapshotable : True
IsSymLink : False
Name : labvsm007
ObjectPath : /datacenter/VDI.cluster/labvsm007.vm
ObjectType : Vm
ObjectTypeName : vm

3. Now we will need to run another PowerShell command to find machines with specific Power State. In our circumstance where BOSVSM007 was reporting with a Power State OFF we’ll run the following command:

Get-BrokerMachine -PowerState Off | Out-File –Filepath C:\broker-state-off.txt

4. The output of this file will list all the machines that are currently in a state of OFF, were again looking for specific machine BOSVSM007 so perform a Find and you’ll see an example that looks like below. You’ll notice the HostedMachineId (4234e84b-6723-0e69-06ea-2543bab2afce) doesn’t match the Id (4be83442-2367-690e-06ea-2543bab2afce) from our earlier output above, and this is where the issue is and we need to correct this within database by running command in our next step.
gentVersion :
AllocationType : Static
ApplicationsInUse : {}
AssignedClientName :
AssignedIPAddress :
AssignedUserSIDs : {S-1-5-21-2825674128-16851514-2748543733-2108}
AssociatedTenantId :
AssociatedUserFullNames : {Lastname, Firstname}
AssociatedUserNames : {LAB\user01}
AssociatedUserSIDs : {S-1-5-31-2825674128-16851514-2748543733-2108}
AssociatedUserUPNs : {user01@lab.local}
BrowserName : Enterprise Static Desktops $P122
Capabilities : {CBP1_5, ReRegisterNow, PvdProgress, LeasedConnection…}
CatalogName : MC-XenDesktop-Static-Manual-Desktops
CatalogUUID : 87d78bbd-0ea1-4268-bfd3-91701d7724d9
CatalogUid : 5
CbpVersion : v1_5
ColorDepth :
ControllerDNSName : deliverycontroller01.lab.local
DNSName : LABVSM007.lab.local
DeliveryType : DesktopsOnly
Description :
DesktopConditions : {}
DesktopGroupName : Enterprise Static Desktops
DesktopGroupUUID : ff0618ec-d605-41ed-a1aa-a016d2227df6
DesktopGroupUid : 5
DesktopKind : Private
DesktopUid : 122
FaultState : None
FunctionalLevel : L7_9
HostedMachineId : 4234e84b-6723-0e69-06ea-2543bab2afce
HostedMachineName : labvsm007
HostingServerName : labesx.lab.local
HypHypervisorConnectionUid : 120919fe-7e98-47bd-b8e2-8600d516207f

5. In this step we’ll update the Citrix SQL database with correct HostedMachineId from our Step 1 output (Please double check all previous output to assure you have correct IDs in question and assure you’ve recorded all previous IDs in question in the event you need to revert changes).

Set-BrokerMachine -MachineName ‘LAB\LABVSM007’ -HostedMachineId 4be83442-2367-690e-06ea-2543bab2afce

6. Now we need to go to VMware https://labesx.lab.local/vsphere-client/ and shutdown the machine in question LABVSM007 and go back to Citrix Studio console and click on the machine and choose Start. It should successfully start machine and upon choosing refresh in console you should now see Power State ON and shortly after the Registration to Registered.

7. Please have end-user validate they can connect to their Enterprise Static Desktop once the Registration changes to Registered.

Get Users of a AD Group

Monday, June 12th, 2017

dsquery group domainroot -name ADGroupName | dsget group -members | dsget user -samid > c:\ADGroupName-Members-samid.txt