Link to home
Start Free TrialLog in
Avatar of llarava
llaravaFlag for Afghanistan

asked on

Get-XASession - Citrix commands must be executed at the Citrix server or using remoting. Make sure that your user accou

Running the following PS script on a Citrix server and getting the following message can someone help?

Citrix SDK cmdlet has been installed locally on the Citrix server.

Get-XASession : Citrix commands must be executed at the Citrix server or using remoting. Make sure that your user accou
nt is a Citrix administrator and that the IMA service is started.
At line:2 char:43
+     [array]$ActiveSessions = Get-XASession <<<<   | Where-Object  { $_.Protocol -eq "ICA" -and $_.State -eq "Active"}
    + CategoryInfo          : InvalidOperation: (:) [Get-XASession], InvalidOperationException
    + FullyQualifiedErrorId : ImaInteropError,Citrix.XenApp.Commands.GetSessionCmdlet

Add-PSSnapin Citrix* -ErrorAction SilentlyContinue

Function ApplyPatchesAndReboot
{
[string]$StartExe = "c:\windows\syswow64\ApplyPatchesAndreboot.exe"
[string]$StartExeArgs = "/noreboot"
start-process $StartExe $StartExeArgs -Wait

}


do {
	[array]$ActiveSessions = Get-XASession  | Where-Object  { $_.Protocol -eq "ICA" -and $_.State -eq "Active"}
	If ($ActiveSessions.length -gt 0)
	{
		Start-Sleep -Seconds 1800
	}

    } while ($ActiveSessions.Count -gt 0 )

"Started installation" | add-content c:\temp\results.log
ApplyPatchesAndReboot
"Finished installation" | add-content c:\temp\results.log

Open in new window

Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

start-> services.msc
find the service name  "IMA Service"   and right click -> start
hope you are using citrix administrator account (your login)
if you dont login with citrix administrator login credentials, then you can do the following:

replace the following line :
[array]$ActiveSessions = Get-XASession  | Where-Object  { $_.Protocol -eq "ICA" -and $_.State -eq "Active"}

with this:
[array]$ActiveSessions = Get-XASession -Account domain\user  | Where-Object  { $_.Protocol -eq "ICA" -and $_.State -eq "Active"}

replace domain\userA  with actual domain and username above
ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the account has to be the farm admin to execute the session data either remoting or from citrix server