Forum Discussion
I am using below powershell script to run and gather citrix Active and Disconnected sessions count. I can gather the data from some machines and it simply doesn't return anything on some machines. When I run poll it says timeout from Logic monitor, so the question I have is how do we find out is the problem with powershell script or with Logic monitor as the script runs fine when run locally on each machine in powershell ISE.
try
{
$icacgpactive = 0
$icacgpdisc = 0
$Citrix_Connect = [ordered]@{}
Get-CimInstance -Namespace ROOT\citrix\EUEM -Query "SELECT * FROM Citrix_Euem_ClientConnect" -ComputerName ##system.hostname## -OperationTimeoutSec 1 -ErrorAction Stop | ForEach-Object {
$Citrix_Connect.Add($_.Username, $_.WinstationName)
}
$Citrix_Disconnect = [ordered]@{}
Get-CimInstance -Namespace ROOT\citrix\EUEM -Query "SELECT * FROM Citrix_Euem_ClientDisconnect" -ComputerName ##system.hostname## -OperationTimeoutSec 1 -ErrorAction Stop | ForEach-Object {
$Citrix_Disconnect.Add($_.Username, $_.WinstationName)
}
foreach($k in $Citrix_Connect.Keys)
{
if( $Citrix_Disconnect[$k] -eq "")
{
if ($Citrix_Connect[$k] -like "ica-cgp#*") { $icacgpactive += 1 }
}
elseif($Citrix_Disconnect[$k] -eq $Citrix_Connect[$k])
{
if ($Citrix_Disconnect[$k] -like "ica-cgp#*") { $icacgpdisc += 1 }
}
else
{
if ($Citrix_Connect[$k] -like "ica-cgp#*") { $icacgpactive += 1 }
}
}
Write-Host "ICACGPActive:$icacgpactive"
Write-Host "ICACGPDisc:$icacgpDisc"
$Exitcode = 0
Write-host "Exitcode:$Exitcode"
}
catch
{
$_.Exception
$Exitcode = 1
Write-host "Exitcode:$Exitcode"
}