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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
This will just give the number.
($ProcessList | Measure-Object -Property WorkingSetPrivate -Sum).Sum

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", 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
Challenges in Government Cyber Security

Has cyber security been a challenge in your government organization? Are you looking to improve your government's network security? Learn more about how to improve your government organization's security by viewing our on-demand webinar!

bibi92Author Commented:
gwmi Win32_PerfFormattedData_PerfProc_Process return the last process id
0
Qlemo"Batchelor", 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
Qlemo"Batchelor", 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
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Then points should get split.
0
bibi92Author Commented:
yes it's an error. How can I split?  thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.