How To Get a Unique STA ID for each of your PVS Provisioned XenApp Servers

How To Get a Unique STA ID for each of your PVS Provisioned XenApp Servers

Citrix Provisioning Services is very nice, but it does come with a slightly annoying quirk: All of your provisioned XenApp servers end up with the same STA ID! This will cause all sorts of problems for Citrix Access Gateway, Citrix Receiver, and anything else that may depend on having unique STA IDs. The good news is that fixing this little problem is easier than you might think.

To resolve the duplicate STA ID issue, we’ll do the following:
1. Create personality strings in Provisioning Services for each XenApp server
2. Put a PowerShell script on our golden image
3. Create a startup task to execute the PowerShell script

Let’s begin:

The format of the STA ID is simple. It is “STA” followed by the MAC address of the XenApp server’s NIC. The STA ID can really be anything beginning with “STA”, so you could get creative and have “STABLEFLY”, “STANK”, “STALE”, “STARTBUTTON”, “STACKOVERFLOW”.. and the list goes on. But I recommend sticking with the MAC address because it’s unique (usually), and is easy to match up.

1. In Provisioning Services, create a personality string for each server with the Name “UID” and the String “STA001122DDEEFF”, substituting the MAC address of the server for the hex I just threw in there.
Define Personality Strings

2. Copy this PowerShell script to your scripts location on your golden image: (Note: Download the file from the above link and do not copy and paste the text below, otherwise PS will complain.)

# STA Replacement Script for Citrix Provisioned Servers
# Created 7-25-11 by Ben Piper (email:, web: )
# Get UID string
# Replace STA ID
# Restart CTXHTTP service

$stastr = get-content C:\Personality.ini | Select-String -Pattern “UID=STA”
$CtxStaConfig = Get-Content ‘C:\Program Files (x86)\Citrix\system32\CtxSta.config’ | ForEach-Object {$_ -replace ‘^UID=.+$’, $stastr}
$CtxStaConfig | Set-Content ‘C:\Program Files (x86)\Citrix\system32\CtxSta.config’
Stop-Service CtxHTTP
Start-Service CtxHTTP

3. Create a scheduled task to execute the PowerShell script at startup. Make sure the account that will be executing the script has appropriate permissions.

If you are not already running PowerShell scripts, you’ll need to set the ExecutionPolicy on your gold image to Unrestricted by issuing the cmdlet ” Set-ExecutionPolicy Unrestricted” at a PS prompt.

I recommend testing the script first on your Master Target server before deploying it farm-wide. The script will still work as long as you have a personality string defined for your Master Target server, even if the vDisk is in Private mode.

Tags: , , , , , ,

2 thoughts on “How To Get a Unique STA ID for each of your PVS Provisioned XenApp Servers

  1. Doesn’t the ‘prepare for imaging’ command of XenApp make the STA unique? If you run it everytime you update the golden master, just before shutting down, everything should be OK, as the XA server wil re-configure itself (and it’s STA) everytime it boots.

    1. The STA written to CtxSta.config is unique, however, when the Master Target is deployed to the provisioned servers, they all end up with the same STA ID because they are all using the same image. According to the Citrix eDocs:

      During the resealing process, the updated Server Configuration Tool:

      Removes server-specific information, such as WSID in MF20.dsn, WSID in RadeOffline.dsn.
      Creates a unique Secure Ticket Authority (STA) ID in CtxSta.config, using the MAC address.

      I have read reports that checking the “Remove this current server instance from the farm” checkbox in the XenApp Server Configuration Tool will cause a unique STA ID to be generated when the provisioned servers boot, but I have not tested this myself. Regardless, I prefer using the script because it eliminates the possibility of a production outage due to a small mistake like forgetting to check the checkbox.

Comments are closed.