PowerShell parsing help

6 views
Skip to first unread message

Dave Lum

unread,
Dec 24, 2025, 1:43:55 PM (6 days ago) Dec 24
to ntsys...@googlegroups.com

Happy holidays y’all!

I have a PS command:
Get-Counter -Counter "\ServerAApplication1(*)\Sessions Active"

 

That gives this output:
Timestamp                  CounterSamples                                                                                     

---------                  --------------                                                                                     

12/24/2025 10:33:06 AM     \\ServerAApplication1(instance1)\sessions active :                        

                           0                                                                                                  

                                                                                                                               

                           \\ServerAApplication1(instance2)\sessions active :                                     

                           4                                                                                                  

                                                                                                                               

                           \\ServerAApplication1(instance3)\sessions active :                                    

                           0       


I can’t figure out how to operate the split command to get only the values after the “:”

All I care about is the session count, and when
- at least one of them isn’t zero, recheck in 30 seconds

- when all are at zero, do this thing

and it’s probably stupidly easy. The IF stuff I can figure out

Can someone help me out? Thanks!

Dave

Attention: Information contained in this message and or attachments is intended only for the recipient(s) named above and may contain confidential and or privileged material that is protected under State or Federal law. If you are not the intended recipient, any disclosure, copying, distribution or action taken on it is prohibited. If you believe you have received this email in error, please contact the sender with a copy to compl...@ochin.org, delete this email and destroy all copies.

Andrea 'ML' Suatoni

unread,
Dec 24, 2025, 5:15:47 PM (6 days ago) Dec 24
to ntsys...@googlegroups.com

It's because CounterSamples is not the apparent multi-line string shown by the cmdlet output, but an array of objects. In fact, you shouldn't need to split anything, as the values you are after are already in their own fields.

The line below should help in better understanding what your are dealing with:

(Get-Counter -Counter "\ServerAApplication1(*)\Sessions Active").CounterSamples |fl *

Andrea
Attention: Information contained in this message and or attachments is intended only for the recipient(s) named above and may contain confidential and or privileged material that is protected under State or Federal law. If you are not the intended recipient, any disclosure, copying, distribution or action taken on it is prohibited. If you believe you have received this email in error, please contact the sender with a copy to compl...@ochin.org, delete this email and destroy all copies. --
You received this message because you are subscribed to the Google Groups "ntsysadmin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntsysadmin+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ntsysadmin/DM8PR17MB49186EB197DBC746161737EBDDB2A%40DM8PR17MB4918.namprd17.prod.outlook.com.

Dave Lum

unread,
Dec 24, 2025, 5:48:17 PM (6 days ago) Dec 24
to ntsys...@googlegroups.com

I’ll be damned, THANK YOU SO MUCH!   Bazinga.


CookedValue      : 3

RawValue         : 3

SecondValue      : 0

MultipleCount    : 1

CounterType      : NumberOfItems32

Timestamp        : 12/24/2025 2:40:01 PM

Timestamp100NSec : 134110608017480000

Status           : 0

DefaultScale     : 0

TimeBase         : 10000000                                                                                          

Dave

 

From: ntsys...@googlegroups.com <ntsys...@googlegroups.com> On Behalf Of Andrea 'ML' Suatoni
Sent: Wednesday, December 24, 2025 2:16 PM
To: ntsys...@googlegroups.com
Subject: Re: [ntsysadmin] PowerShell parsing help

 

CAUTION: This email originated from outside of OCHIN’s network

Do not click links or open attachments unless you recognize the sender and know the content is safe. If you suspect this email is phishing or a scam, use the report button in the Outlook toolbar to report it to Desktop Support.

 

Reply all
Reply to author
Forward
0 new messages