[PowerShell] Citrix XenDesktop SDK – Suppress Citrix Workspace Cloud prompt

Summary

Citrix XenDesktop PowerShell SDK – Suppress Citrix Workspace Cloud prompt when using -AdminAddress parameter

Issue

When invoking commands locally on a delivery controller this is not an issue. However when attempting to communicate with a delivery controller using the –AdminAddress parameter you are prompted with the following prompt:

clip_image002

The Citrix PowerShell SDK states the following:

To bypass the authentication prompt, you can use the Set-XdCredentials cmdlet to create a default authentication profile, using a Secure Client created in the Citrix Cloud console.

https://docs.citrix.com/en-us/citrix-cloud/xenapp-and-xendesktop-service/remote-powershell-sdk.html

However if you aren’t connecting to cloud services this is not ideal.

You could use remote PowerShell to run the script on a delivery controller, but if you are doing complex functions it is a risk to run all processing on a production broker.

Resolution:

In order to work around this issue you can use a cool function in PowerShell called Import-PSSession (https://technet.microsoft.com/en-us/library/hh849970.aspx).

What this commandlet does is allow you to import cmdlets, functions and aliases from an existing PowerShell Session (local or remote).

We can use this commandlet to import the PowerShell modules from the delivery controller but keep all processing local to the client the script is running from.

Implementation

# Initialise variables/Parameters
$strController = "cm-ddc-01"	# Delivery controller address

# Get User Credentials - uncomment if you are not running as an account with
# appropriate permissions to interact with Delivery Controller
#If($objUser.count -le 0){
#	$objUser = Get-Credential
#}

# Create new Remote PowerShell session
$objRemoteSession = New-PSSession -ComputerName $strController #-Credential $objUser # Uncomment -credential .. if get-credential
# Use Invoke-Command to import Citrix PowerShell snap-ins on remote server
Invoke-Command -ScriptBlock {add-pssnapin Citrix.*} -Session $objRemoteSession
# Import PowerShell session
Import-PSSession -Session $objRemoteSession -Module Citrix.* -Prefix RM

# You can now use any Citrix PowerShell commandlet by prefixing it with RM
# Example Get-BrokerMachine is now Get-RMBrokerMachine
Get-RMBrokerMachine
Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s