XenApp Machine Power State Uknown or Incorrect

Issue: Citrix Studio showing the power state for a machine as Unknown or incorrect (i.e. Studio says the machine is On when it’s in fact powered off or vice versa) following a vcenter outage.

I have quite quickly found https://support.citrix.com/article/CTX131267?_ga=2.83298006.1304926953.1588149335-464024711.1570620116 and following the instructions established that the Machine IDs are mismatched between the Citrix and vCenter databases.

To check quickly check:

  1. On a Citrix Delivery Controller run the following in powershell:

    asnp Citrix*
    Get-BrokerMachine | Select-Object -Property MachineName, PowerState, RegistrationState, HostedMachineId

    This will give you details for each machine as they are in the Citrix database.

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

    This will give you details from vmware.

  3. Look up one of the problem machines in xdhyp.txt and compare the ID with the HostedMachineID from step 1. You should see that they are different.

The Citrix article would have you believe that you can change the ID in the Citrix database by running

Set-BrokerMachine -MachineName ‘MyDomain\MyMachine’ -HostedMachineId

However this will error with:

Set-BrokerMachine : The term ‘Set-BrokerMachine’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

To get around this you will need to edit the vmx files of the affected machines with the HostedMachineID from the Citrix Database.

This is fine if you only have a handful of machines to correct but otherwise it might be quicker to just delete those machines and create new ones. I’m not sure if editing the Citrix Database directly would also be an option.

Editing the vmx files:

  1. Shutdown the machine
  2. Browse the datastore the machine is on and download the machinename.vmx file.
  3. Open in notepad and search for “uuid.bios
  4. You should see this is different to the HostedMachineID you’ve got earlier and matches the ID from the xdhyp.txt file.

    “uuid.bios = “56 4d 01 d4 26 c8 9a bf-fa 27 b5 74 61 70 0e f2”

  5. Replace the uuid.bios value with the HostedMachineID making sure you follow the same format. For example if the powershell output looks like this:
    42061861-553b-950b-55a3-6da713ee701e
    edit it into the following format:
    42 06 18 61 55 3b 95 0b-55 a3 6d a7 13 ee 70 1e
  6. Save the vmx file.
  7. Remove the vmx file from the datastore (make sure you have a copy).
  8.  Upload the edited vmx file into the datastore.
  9. Power the machine back on and you should see the correct Power Status in Citrix Studio.

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s