Hi all,
Been fiddling with PowerShell last couple of days, but there's this thing I can't get my head around.
Let's say I'd like some message if HTTP-GET requests are happening on SomeSite. I'd think I'd need a syntax like:
if((Get-Counter -counter "\Web Service(SomeSite)\Get Requests/sec") -ne 0) {Write-Host "We received" $_ "GET requests last sec"}
The above does not work, because Get-Counter, like all cmdlets, outputs (a table showing) objects of various types, inlcuding a header. In this example an object of type 'System.Object.PerformanceCounterSampleSet' is returned.
I'm used to cmd scripting, and never had to deal with anything else then strings and ints. I'm confused how I can get Get-Counter to return just an int value.
Been fiddling with PowerShell last couple of days, but there's this thing I can't get my head around.
Let's say I'd like some message if HTTP-GET requests are happening on SomeSite. I'd think I'd need a syntax like:
if((Get-Counter -counter "\Web Service(SomeSite)\Get Requests/sec") -ne 0) {Write-Host "We received" $_ "GET requests last sec"}
The above does not work, because Get-Counter, like all cmdlets, outputs (a table showing) objects of various types, inlcuding a header. In this example an object of type 'System.Object.PerformanceCounterSampleSet' is returned.
I'm used to cmd scripting, and never had to deal with anything else then strings and ints. I'm confused how I can get Get-Counter to return just an int value.