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.

 

 

Test Checklist for Citrix XenApp Deployment

While this won’t fit the bill for all your Citrix XenApp deployments I wanted to share what I like to test at the end of a new deployment as I couldn’t find much online when I looked for guidance. I’d very much welcome any suggestions to make this more comprehensive and will add them to a future edits of this post.

For a bit of a background this deployment involved installing new HP Servers and  deploying VMWare ESXi. Hence the test sections relating to those. There was very minimal NetScaler Access Gateway reconfiguration to reference the new StoreFront servers.

System Testing

HPE iLO and Hardware Status

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/HPE/001 From a PC connected to the internal data network login via http://ESX01-ILO.DOMAIN.LOCAL. Confirm login to iLO interface succeeds.
UAT/HPE/002 From a PC connected to the internal data network login via http://ESX02-ILO.DOMAIN.LOCAL. Confirm login to iLO interface succeeds.
UAT/HPE/003 From a PC connected to the internal data network login via http://ESX03-ILO.DOMAIN.LOCAL. Confirm login to iLO interface succeeds.
UAT/HPE/004 From a PC connected to the internal data network login via http://ESX04-ILO.DOMAIN.LOCAL. Confirm login to iLO interface succeeds.
UAT/HPE/005 On ESX01-ILO.DOMAIN.LOCAL confirm System Health displayed as OK and no hardware or configuration issues are shown.
UAT/HPE/006 On ESX04-ILO.DOMAIN.LOCAL confirm System Health displayed as OK and no hardware or configuration issues are shown.
UAT/HPE/007 On ESX03-ILO.DOMAIN.LOCAL confirm System Health displayed as OK and no hardware or configuration issues are shown.
UAT/HPE/008 On ESX04-ILO.DOMAIN.LOCAL confirm System Health displayed as OK and no hardware or configuration issues are shown.
UAT/HPE/009 On ESX01-ILO.DOMAIN.LOCAL launch remote console and confirm connection to the server.
UAT/HPE/010 On ESX02-ILO.DOMAIN.LOCAL launch remote console and confirm connection to the server.
UAT/HPE/011 On ESX03-ILO.DOMAIN.LOCAL launch remote console and confirm connection to the server.
UAT/HPE/012 On ESX04-ILO.DOMAIN.LOCAL launch remote console and confirm connection to the server.

VMWare

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/ESX/001 From a PC connected to the internal network browse to https://esx01.domain.local and confirm successful logon.
UAT/ESX/002 From a PC connected to the internal network browse to https://esx02.domain.local and confirm successful logon.
UAT/ESX/003 From a PC connected to the internal network browse to https://esx03.domain.local and confirm successful logon.
UAT/ESX/004 From a PC connected to the internal network browse to https://esx04.domain.local and confirm successful logon.
UAT/ESX/005 Login to https://vcenter.domain.local and confirm ESX01, ESX02, ESX03 and ESX04 are all being managed by vcenter.
UAT/ESX/006 While connected to https://vcenter.domain.local confirm no alerts which would indicate hardware or configuration issues are shown on cluster “XenAPP”. Success
UAT/ESX/007 While connected to https://vcenter.domain.local confirm virtual machine start up settings are set as expected. Success

NetScaler

The NetScaler tests are focused on newly configured functionality only such as NetScaler Gateway and load balancing virtual servers.

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/NS/001 Login via http://citrix.company.org.uk
UAT/NS/002 Launch published desktop via http://citrix.company.org.uk
Standard Desktop
Staging Desktop
Finance Desktop
IT Desktop
UAT/NS/003 Log off http://citrix.company.org.uk
UAT/NS/004 Disconnecting network on STOREFRONT01 results in requests being directed to STOREFRONT02
UAT/NS/005 Disconnecting network on STOREFRONT02 results in requests being directed to STOREFRONT01
UAT/NS/006 Browser requests sent to http://citrix.company.org.uk are redirected to https://citrix.company.org.uk/Citrix/company/PNAgent/config.xml. This is to allow for redirection of HP Thin Clients which can’t be reconfigured. I would normally test a simple http to https redirection
UAT/NS/007 Login via https://myoffice.company.org.uk  (from an external network)
UAT/NS/008 Launch published desktop via https://myoffice.company.org.uk (from an external network)
Standard Desktop
Staging Desktop
Finance Desktop
IT Desktop
UAT/NS/009 Log off https://myoffice.company.org.uk (from an external network)
UAT/NS/010 Configure an iOS device for https://myoffice.company.org.uk and launch desktop.
UAT/NS/011 Configure Citrix Receiver for Windows for https://myoffice.company.org.uk and launch desktop.
UAT/NS/011 From vSphere web client confirm NetScaler01 and NetScaler02 have been moved over to the new XenApp cluster.

Storefront

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/SF/001 Published desktops and applications enumerated as expected following logon to https://citrix.company.org.uk    
UAT/SF/002 Login to Desktop Appliance site https://citrix.company.org.uk/Citrix/StoreDesktopAppliance    
UAT/SF/003 Desktop is auto launched upon login to https://citrix.company.org.uk/Citrix/StoreDesktopAppliance    
UAT/SF/004 Log off from https://citrix.company.org.uk/Citrix/StoreDesktopAppliance    
UAT/SF/005 Confirm successful launch of Application1    
UAT/SF/006 Confirm successful launch of Application2    
UAT/SF/007 Confirm successful launch of Application3    
UAT/SF/008 Confirm successful launch of Application4    

Desktop Delivery Controllers

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/DDC/001 Run Site configuration test in Citrix Studio and confirm no warnings or failed tests are identified.    
UAT/DDC/002 Run machine catalog test in Citrix Studio against each catalog (Standard Desktop, IT Desktop, Finance Desktop, Staging Desktop, Application delivery) and confirm no warnings or failed tests are identified.    
UAT/DDC/003 Run delivery group test in Citrix Studio against each delivery group (Standard Desktop, IT Desktop, Finance Desktop, Staging Desktop, Published Applications) and confirm no warnings or failed tests are identified.    
UAT/DDC/004 Sessions are distributed across session hosts.    
UAT/DDC/005 Correct license information is displayed for the farm in Citrix Studio (500 XenApp Enterprise concurrent licenses).    
UAT/DDC/006 Disconnecting network on CTXDEL01 results in requests being handled by CTXDEL02.    
UAT/DDC/007 Disconnecting network on CTXDEL01 results in requests being handled by CTXDEL02.    

Citrix License Server

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/LIC/001 XenApp Enterprise Licenses shown in License Administration Console.    
UAT/LIC/002 Users aren’t presented with any license related errors on logon.    
UAT/DC/003 Members of “Domain Admins” can successfully login to the License Administration Console. To be tested against Patrick’s logon.    

Terminal Services Licensing

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/RDS/001 Logon to lic01.domain.local, open RD Licensing manager and confirm Windows Server 2012 are present and license server activated.    
UAT/RDS/002 Logon to lic01.domain.local, open RD Licensing manager and confirm licenses are being issued by the server.    
UAT/RDS/003 Users aren’t presented with any license related errors on logon on to session host servers.    
UAT/RDS/004 Run gpresult on a session host and confirm License servers to use is set to LIC01.    

Citrix Director

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/DIR/001 Members of Domain Admins can login to Citrix director at http://ctxdir01.domain.local/director/  to be tested with Patrick’s account.    
UAT/DIR/002 All session hosts are visible to from Citrix Director.    
UAT/DIR/003 Confirm successful session shadowing.    

Local Host Cache

The Local Host Cache (LHC) feature allows connection brokering operations in a XenApp or XenDesktop Site to continue when site database outage occurs. To simulate an outage the SQL instance sql01\CITRIX will be stopped.

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/LHC/001 Verify a new connection can be made to the farm by launching published desktop.    

Client Testing

This section covers connectivity to the new Citrix XenApp 7.15 site from a variety of clients.

Internet Explorer Browser

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/IE/001 Login to https://citrix.company.org.uk. Confirm successful logon.    
UAT/IE/002 Confirm desktops/applications are listed as expected.    
UAT/IE/003 Launch publish desktop and confirm successful launch.    
UAT/IE/004 Log out from desktop without errors.    
UAT/IE/005 Log out from Storefront without errors.    

IGEL Thin Client

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/IG/001 Login to https://citrix.company.org.uk. Confirm successful logon.    
UAT/IG/002 Confirm desktops/applications are listed as expected.    
UAT/IG/003 Launch publish desktop and confirm successful launch.    
UAT/IG/004 Log out from desktop without errors.    
UAT/IG/005 Log out from Storefront without errors.    

HP Thin Client

Task ID Task Description Result (Success/Fail) Remedial Action Required / Notes
UAT/HP/001 Login to https://citrix.company.org.uk/Citrix/StoreDesktopAppliance. Confirm successful logon.    
UAT/HP/003 Confirm desktop is auto launched as expected.    
UAT/HP/004 Log out from desktop without errors.    
UAT/HP/005 Log out from Storefront without errors.    

User Testing

The client would normally define their testing criteria.

Overall Test Result PASS/FAIL
All tests have been carried out successfully.  
Test Plan results verified with  
Customer Contact Signature  
Date  

XenDesktop: Migrating dedicated catalog to another datastore

If you are looking to move your virtual machines to another datastore chances are you have already come across this Citrix article: How to Migrate Dedicated Catalog to Another Datastore.

Last week I have unsuccessfully attempted to follow it and thought I would clarify a couple of ambiguous points in the guide and it’s indented application.

First of all I need to point out that if you intend to move your base image file this guide isn’t going to do it for you. While you are asked to copy the base image to the new datastore it doesn’t tell you to delete it from the old location. This is because all the delta disks you move will still be referencing the original base image file location. So if you are hoping to decommission  some old storage and need everything to move, Citrix recommend you convert the linked clones to full clones – you can achieve this by a simple storage migration in vSphere. You can then remove them from the catalog and add again as existing. There is an inevitable increased storage requirement which is what you were probably trying to avoid in the first place but it is the safest and most reliable way of doing this.

You could also look at editing the vmdk configuration files of your moved VMs and setting parentFileNameHint to the new file path – I will delve deeper into this in a future post.

If the Citrix guide still fits the bill for you here are the parts that I found slightly unclear. Some of them may seem obvious but as I things weren’t working out for me I was questioning every step.

Step 5:

Copy vmdk to new storage.

VMware PowerCli command:

Copy-DatastoreItem 'vmstore:\vc-servername\source_datastore\ contosow7-baseDisk-datastore-11\*' 'vmstore:\vc-servername\dest_datastore\ contosow7-baseDisk-datastore-11\' -Force

After copy has been completed, base disk will be converted to thick format; diff disk will remain thin-provisioned.

What Citrix want you to do here is to copy all your machine’s deltas and the base image file over to the new datastore. The command above assumes they are all within the same folder (contosow7-baseDisk-datastore-11) but depending on how you have the files organised you might need to copy the base image file separately. You will also likely have your vmx and other configuration files in the same location and these will be copied over at the same time. These won’t be used for anything as when you recreate the machines a new folder will be create for each one. In effect there will a be some doubling up but nothing to worry about as the storage use will be negligible. You can also manually copy the files using the vSphere client and the effect will be the same.

Step 6:

Back up the base and diff disk folder defined in the filename column of the contoso_disk.csv file. Delete the machines to be migrated through the desktop studio console and choose the options to “Remove the accounts from the Catalog but do not remove them from Active Directory”.

You should already have  a copy of all this on your new datastore but you might want to backup within the same datastore to reduce the restore time if required. When you delete the machines from the catalog the diff disks will be deleted but the base image will remain intact anyway.

Step 7:

Create new machines with existing disks. (Import.csv) file is used with the columns shown in the following table.

VMName LastConnectionUser OldDiskPath NewDiskPath
contosow7AAA contoso\user1 [source_datastore] contosow7-baseDisk-datastore-11/contosow7-baseDisk-datastore-217-000005.vmdk [dest_datastore] contosow7-baseDisk-datastore-11/contosow7-baseDisk-datastore-217-000005.vmdk

VMware PowerCli command:
Import-Csv importcsv.csv -UseCulture | %{
$vm = New-VM -Name $_.VMName -VMHost 20.10.102.12 -MemoryMB 2048 -NumCpu 2 -GuestId “windows7_64Guest” -NetworkName “VLAN 123”  -Datastore “Dest_Datastore” -DiskPath $_.NewDiskPath
}

The OldDiskPath isn’t used during the machine creation at all so you don’t need to worry about it too much. The NewDiskPath is the path for the machine’s delta – not the base image file.

Hope this helps to avoid at least some of the confusion.

Did you know?

Well I didn’t. More specifically I didn’t know that Server 2008 behaves quite differently to 2003 when it comes to choosing a source IP address on a server with multiple IP addresses on the same interface.

Previously on Server 2003 the source address would be the primary address on the interface in question. This address would also register in DNS. Server 2008 and higher uses the address which has the most bits in common with the default gateway. This is worked out in binary and I won’t bore you with the details. To make this a little bit easier on us Microsoft have released a hotfix which introduces the SkipAsSource flag. To use it you have to remove the IP addresses and re-add them using the netsh command.

For example:

netsh Int IPv4 Add Address <Interface Name> <IP Address> SkipAsSource=True

To check that the command worked as expected run:

Netsh int ipv4 show ipaddresses level=verbose

You should see something like this:

skipassource

In case you can’t see the Skip as Source setting you still need the install the hotfix above.

You would hope that you’re done at this stage but there are some issues with this hotfix and you will need to install two more:

 

KB2554859: The “skipassource” flag of IP addresses is cleared after you use the GUI to change IP settings of a network adapter in Windows 7 or in Windows Server 2008 R2

KB2551090: IIS Manager does not display IP addresses that are assigned to the network adapter together with the skipassource flag

This does the trick and gives you control over which addresses are registered in DNS and used as source.

References:

https://blogs.technet.microsoft.com/networking/2009/04/24/source-ip-address-selection-on-a-multi-homed-windows-computer/

http://blogs.technet.com/b/rmilne/archive/2012/02/08/fine-grained-control-when-registering-multiple-ips.aspx#pi63079=2