Run Citrix PowerShell commands remotely



Let’s say you have a script written in PowerShell for your Citrix environment and want to deploy it through Jenkins. How’d you do that? If you directly run a PowerShell script from a Jenkins machine (not Citrix DDC), you will end up in “The caller was not authenticated by the service” error.

Through Jenkins, you have to specify credentials. In VMWare PowerCli, we have -credential parameter using which we can specify explicit credentials. But with Citrix PowerShell snapins, we do not have that option. So, What is the solution?

The answer is by creating a PSsession to your Citrix server and importing Citrix PowerShell snapin in that PSsession. One other benefit of using this way is, you don’t have to install any Citrix PowerShell snapins in the machine you’re running this script from.

#Create PSsession on your DDC.
$Session = New-PSsession -Computername "CitrixServerName"
#Add Citrix PowerShell Snapins in the session.
Invoke-Command -Command {add-pssnapin Citrix.*} -Session $Session
#Import the session created above and a new prefix to all the Citrix commands.
Import-PSSession -Session $Session -Module Citrix.* -Prefix Ctx

In your script, you can now run the Citrix PowerShell commands by adding the prefix. For example, Get-BrokerSession cmdlet now becomes Get-CtxBrokerSession.


  1. You have to be part of the local administrators group on the Citrix server to create pssession.
  2. If you are integrating the script with Jenkins, you can use invoke-command and then run the above script in the invoke-command script block.


Want to learn more on Citrix Automations and solutions???

Subscribe to get our latest content by email.