Forum Discussion

RajeshP's avatar
4 years ago

when running the script using gwmi it just timeout without returning anything

when running the script using gwmi it just timeout without returning anything

5 Replies

  • Anonymous's avatar
    Anonymous

    I'm sorry, but I think we're gonna need more details around the problem before we can even know what you're talking about. 

    That said, looks like you're trying to use WMI. If that's the case, have you tried this?

  • 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"
        }

  • Anonymous's avatar
    Anonymous

    Your erroraction is set to stop. I'm not a PS guy, are there other options that would give you more info? Have you verified that the permissions for the account running the Collector service are the same across all the systems you're trying to poll?

  • the default wmi query calls from Logic monitor is able to poll data, but when adding a powershell script to poll data it is getting timedout. 

    Do we need any specific option or setting to enable or is it due to some other issues ?

  • Anonymous's avatar
    Anonymous
    2 hours ago, RajeshP said:

    the default wmi query calls from Logic monitor is able to poll data, but when adding a powershell script to poll data it is getting timedout. 

    You mean to say that other DataSources that use the built in WMI collector work without any special configuration, but when trying to run PowerShell, it times out?

    There shouldn't be anything you need to do to the collector to get it to work. You might try running your script in the Collector debug console using !posh. It could be that you need to pull the wmi.user and wmi.pass properties into your script and pass the credentials explicitly.