for processes powershell do a sum of WorkingSetPrivate

Hello,

How can I modifiy this script for doing a sum of WorkingSetPrivate for all processes Powershell :

If ($ProcessName -eq "Powershell") {
  $ProcessList = gwmi Win32_PerfFormattedData_PerfProc_Process | where {$_.Name -eq $ProcessName} | select IDProcess,Name,WorkingSetPrivate | sort WorkingSetPrivate -Descending | select -First $SelectFirst
}

Thanks

Regards
bibi92Asked:
Who is Participating?
 
footechCommented:
This will just give the number.
($ProcessList | Measure-Object -Property WorkingSetPrivate -Sum).Sum

Open in new window

0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
If ($ProcessName -eq "Powershell") {
  $WSP = gwmi Win32_PerfFormattedData_PerfProc_Process | where {$_.Name -eq $ProcessName} | measure-object -sum WorkingSetPrivate | select -Expand Sum
}

Open in new window

0
 
bibi92Author Commented:
I have tested, the sum WorkingSetPrivate is only the result of the last process, I checked the result in column memory private working set with task manager
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
bibi92Author Commented:
gwmi Win32_PerfFormattedData_PerfProc_Process return the last process id
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Incorrect, the WMI query returns values for all processes including Total, and
gwmi Win32_PerfFormattedData_PerfProc_Process -Filter "name like 'PowerShell%'"

Open in new window

returns all PowerShell processes' values. Your issue is that Name does only match exactly for one process instance, the other ones are enumerated with e.g. "powershell#1".
0
 
bibi92Author Commented:
Ok, I will test it. Thanks
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
bibi, http:#a40688399 will only get you one instance of the process. You'll need to make the process list generated with something like http:#a40689243 to get all instances' values.
0
 
bibi92Author Commented:
yes exactly thanks
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Then points should get split.
0
 
bibi92Author Commented:
yes it's an error. How can I split?  thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.