pavelk
October 9, 2017, 5:43am
1
Hi,
I am trying to monitor each IIS instance on my machine.
There are 3 of them that i can see in perfmon window:
w3wp
w3wp#1
w3wp#2
theCounter from the initiation:
$theCounter=(get-counter -listset Process).PathsWithInstances | Where-Object { $_ -like "*w3wp*" -and
$_ -like "*Processor Time*"}
has following output:
PS C:\Windows\system32> $theCounter
\Process(w3wp)% Processor Time
\Process(w3wp)% Processor Time
\Process(w3wp)% Processor Time
There are same 3 processes , but without the #
It’ss causing problems when I am executing something like:
Get-counter -Counter $theCounter -SampleInterval 2 -MaxSamples 10 | Export-counter -Force -Path C:\theTest.blg
In final BLG file I can see only one line and it is clear why - all numbers were written under same counter name.
There is no possibility here to differentiate between processes.
Any suggestions how can I get counters with the # ?
Thanks.
donj
October 9, 2017, 8:19am
2
I’m not sure the perf counters actually distinguish. From their perspective, it’s just like running multiple copies of Notepad, right? Let me dig into it a bit, though and see if I can figure it out.
pavelk
October 9, 2017, 8:51am
3
Yes, exactly as few Notepads.
Thanks.
pavelk
October 10, 2017, 7:00am
4
I found some workaround using typeperf that gives me an IDs:
$fo = [System.IO.Path]::GetTempFileName()
typeperf -f CSV "\Process(*)\% Processor Time" -sc 1 -o $fo -y | Out-Null
$t = import-csv $fo -Delimiter ","
$t
Now the challenge is to get list of processes names from object $t, filtering it by specific process name “w3wp”…
Any suggestions how to do it?
pavelk
October 17, 2017, 2:54am
5
Hi,
I just created some solution script for the issue.
Putting it here to whom could be interested in it.
It looks like:
function getProcessesWithInstancesCounters($countersList) {
$fo = [System.IO.Path]::GetTempFileName()
typeperf -f CSV $countersList -sc 1 -o $fo -y | Out-Null
$t = (import-csv $fo)
$t=([regex]::replace([regex]::replace([string]$t, "(=[0-9]*)", ""),"[:}]","") | Where-Object {$_ -like '*\\*' })
$t=$t | Out-String
del $fo
$t -split ";"
}
$counters= ((getProcessesWithInstancesCounters (get-counter -ComputerName 1.10.241.61 -listset Process).Paths) | foreach {$_.Trim()} | Where-Object {
$_ -notlike "*Peak*" -and $_ -like "*w3wp*" -and (
$_ -like "*Processor Time*" -or
$_ -like "*Private Bytes*" -or
$_ -like "*Virtual Bytes*" -or
$_ -like "*Working Set*")})
Get-counter -Counter $counters -SampleInterval 2 -MaxSamples 25 | Export-counter -Force -Path D:\DeleteMe\PowerShell\ProcessDetiled.blg
Hello all,
New to this forum
I need to find out properties of particular computers in my domain.
Get-Adcomputer “computername” -properties * | select-object Name -> giving me the outpout for selected computer. Is there any way I can get properties of particular computers in one command.
Kindly help.
THank you
donj
October 26, 2017, 12:57pm
7
Please open a new thread rather than asking an unrelated question on an existing thread. Thank you.