unable to manipulate the get-counter information as needed

This topic contains 3 replies, has 4 voices, and was last updated by Profile photo of Jack Neff Jack Neff 1 year, 11 months ago.

  • Author
    Posts
  • #21629
    Profile photo of Jesse
    Jesse
    Participant

    First of all I am new to this forum and this is my first post so if this is not placed in the correct section I apologize. Also I am not an expert at powershell by any means.

    We use CitrixXenApp 6.5. We would like to get some counter information in a simplified format. This counter is the ICA latency counter, I am able to get the information needed but it comes out in a format that I am not able to manipulate into something more usable for our needs. I need it to be formatted into two columns: user and latency counter stats. When I run the command

    get-counter "\\servername\ICA Session(*)\Latency - Last Recorded" 

    I get an output like the following

    Timestamp CounterSamples
    ——— ————–
    1/5/2015 1:40:47 PM \\servername\ica session(_server total)\latency – last recorded :
    0

    \\servername\ica session(ica-tcp 7 (userA))\latency – last recorded :
    51

    \\servername\ica session(ica-tcp 3 (userB))\latency – last recorded :
    52

    \\servername\ica session(ica-tcp 4 (userC))\latency – last recorded :
    27

    \\servername\ica session(ica-tcp 5 (UserD))\latency – last recorded :
    24

    \\servername\ica session(ica-tcp 2 (UserE))\latency – last recorded :
    25

    \\servername\ica session(ica-tcp 6 (UserF))\latency – last recorded :
    63

    \\servername\ica session(ica-tcp 0 (UserG))\latency – last recorded :
    24

    The problem I have is that I am not able to parse out just the username (userA) and the Last recorded: stat.

    I have done a GM and I get the following

    TypeName: Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet

    Name MemberType Definition
    —- ———- ———-
    Equals Method bool Equals(System.Object obj)
    GetHashCode Method int GetHashCode()
    GetType Method type GetType()
    ToString Method string ToString()
    CounterSamples Property Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample[] CounterSamples {get;set;}
    Timestamp Property datetime Timestamp {get;set;}
    Readings ScriptProperty System.Object Readings {get=$strPaths = ""...

    I tried

    get-counter "\\servername\ICA Session(*)\Latency - Last Recorded"  | select CounterSamples

    CounterSamples
    ————–
    {_server total, ica-tcp 7 (UserA), ica-tcp 3 (UserB), ica-tcp 4 (UserC)...}

    This narrows the information down a bit but still not what I need, As you can see it gives me the username and the TCP type but not the counter information.

    I then tried

    get-counter "\\cltcldssgxa01\ICA Session(*)\Latency - Last Recorded" | select readings

    Readings
    ——–
    \\cltcldssgxa01\ica session(_server total)\latency – last recorded :...

    I am sure I am missing a very simple solution but for the life of me I am not able to figure it out. Any assistance is greatly appreciated.

  • #21636
    Profile photo of Jarek C.
    Jarek C.
    Participant

    It would be useful to see your
    get-counter \\.... | get-member

  • #21681
    Profile photo of Stephen Owen
    Stephen Owen
    Participant

    Hi Jessie,

    Please run

    get-counter "\\servername\ICA Session(*)\Latency – Last Recorded" | Select -first 20 | Export-CSV C:\pathto\export.csv

    and place the file here or on Pastebin or some place.

    We need to see your source info to help you at all, and most of us don't have Citrix servers laying about to query.

    Thanks!

  • #21708
    Profile photo of Jack Neff
    Jack Neff
    Participant

    I'm terrible at regex but for what it's worth:

    $text = "\\servername\ica session(ica-tcp 7 (userA))\latency – last recorded: 51"
    
    $NamePattern = '\s\(\w{2,}\)'
    
    $User = if ($text -match $NamePattern){(($Matches[0].Trim()).TrimStart("(")).TrimEnd(")") }
    
    $Latency = ($text.Split(":") | Select-Object -Index 1).Trim()
    
    "User = $User"
    "Latency = $Latency"
    

    Output:

    User = userA
    Latency = 51
    

You must be logged in to reply to this topic.