I have the following powershell script:

Add-PSSnapin Citrix*
$ComputerName = [string]$Args[0]
if ($ComputerName -eq "")
{
 "<prtg><error>1</error><text>No Computername set in the parameters of the script</text></prtg>"
}
else
{
 $Sessions = Get-XAFarm -ComputerName "$ComputerName"
 $SessionCount = $Sessions.SessionCount
 "<prtg>"
 "<result>"
 "<channel>Current Session Count</channel>"
 "<value>" + $SessionCount + "</value>"
 "</result>"
 "</prtg>"
}

This script gives me the below stated error:

Get-XAFarm : De server kan de aanvraag niet verwerken als gevolg van een intern
e fout. Voor meer informatie over de fout kunt u IncludeExceptionDetailInFaults
 inschakelen (vanuit ServiceBehaviorAttribute of vanuit het configuratiegedrag 
<serviceDebug>) voor de server zodat de uitzonderingsgegevens naar de client wo
rden teruggestuurd, of u kunt tracering inschakelen. Raadpleeg hiertoe de docum
entatie van Microsoft .NET Framework 3.0 SDK en controleer de traceringslogboek
en voor de server.
At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\GetCurrent
XASessionCount.ps1:9 char:14
+  $Sessions = Get-XAFarm -ComputerName "$ComputerName"
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-XAFarm], FaultException
    + FullyQualifiedErrorId : System.ServiceModel.FaultException,Citrix.XenApp 
   .Commands.GetFarmCmdlet
 
<prtg>
<result>
<channel>Current Session Count</channel>
<value></value>
</result>
</prtg>

If i execute the script manually, it works. so what's wrong with my script...


Article Comments

Hi Eagle,

Please try to start the script within another security context by marking Use Windows credentials of parent device in the settings of the sensor. Please ensure that you enter a user who has got sufficient rights to execute scripts on the probe system.

Best regards, Felix


Nov, 2015 - Permalink