Jump to content
Welcome to our new Citrix community!
  • 0

Get-XDAuthentication problem in Azure Automation

Jerome Queneuder




I use a script to build a CMDB and it's executed in an Azure Automation Account on Azure with a Hybrid Worker. In this context, I get an error with Get-XDAuthentication cmdlet. See the full stack below:


Get-XDAuthentication: GetBearerToken: ERROR: System.TypeInitializationException: The type initializer for 'Citrix.CloudServices.ServiceRuntime.ApiClient.ServiceClient' threw an exception. ---> System.MissingMethodException: Method not found: 'Void System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.set_SerializerSettings(Newtonsoft.Json.JsonSerializerSettings)'. at Citrix.CloudServices.ServiceRuntime.ApiClient.ServiceClient..cctor() --- End of inner exception stack trace --- at Citrix.CloudServices.ServiceRuntime.ApiClient.ServiceClient..ctor(String serviceUri, ConnectionSettings connectionSettings, RequestSettings settings, HttpMessageHandler handler, Boolean disposeHandler) at Citrix.CloudServices.ServiceRuntime.ApiClient.ServiceClient..ctor(String serviceUri, HttpMessageHandler handler, Boolean disposeHandler) at Citrix.Sdk.Proxy.Cmdlets.GetXDAuthenticationCmdlet.<GetCwsTokenAsync>d__52.MoveNext() in C:\tc\work\6361d81236d1f614\Cloud\PoshSdkProxySnapIn\Components\Snapin\Cmdlets\GetXDAuthentication.cs:line 654


This cmdlet works correctly when I execute from a remote session on the same server used has a Hybrid Worker.


My Environment is:


Windows Server 2016

Powershell 5.1.14393.3866

Citrix Powershell SDK


Thank you for your help,


Jérôme Queneuder

Link to comment

5 answers to this question

Recommended Posts

  • 0

Hello Daniel,


Not solved but I used Windows Task Scheduler as a workaround. The issue is the method of the library "Newtonsoft.Json" installed by the Hybrid Worker component is not compatible with Citrix PoSH SDK. I asked Citrix and they told me that Microsoft is reponsible of this library, it's right but Citrix could use another library to do the same job and avoid conflict with library versions used between their SDK and the one coming from Hybrid Worker binaries...


If I remember correctly, the issue is described here. It's a global problem when developers use common libraries.

Link to comment
  • 0
On 1/7/2022 at 12:48 PM, Daniel Viklund1709162911 said:

Hi Jerome,

I had no support from Citrix, so I made my own Citrix Cloud Rest API that I use in my Azure Automation.
Been using it for a couple of months now.

Hey, @daniel! Would you mind sharing how you did it? I've been dealing with this recently and haven't gotten a tangible response from Citrix either. Thanks!

Screenshot 2022-01-24 100538.png

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...