Answered by:
I want memory consumed for a process by each user on server

Question
-
I am able to fetch memory consumed by the required process with below command.
get-process -ComputerName $vm.name [ProcessName] | Where-Object {$_.WorkingSet -gt 2GB}
And I am able to fetch users running that process using below command:-
PS P:\> Get-WmiObject Win32_Process -Filter "name='[PROCESS NAME]" | Select ProcessID, Name, @{Name="[USERNAME]";Expression={$_.GetOwner().User}} | Sort-Object UserName, Name, ProcessID
Need help in combining these commands as new to powershell.
Thursday, October 5, 2017 7:22 PM
Answers
-
You can also just do this:
get-process -IncludeUserName | Where-Object {$_.WorkingSet -gt 2GB}
\_(ツ)_/
- Marked as answer by Deep_PS Friday, October 6, 2017 6:16 PM
Thursday, October 5, 2017 8:04 PM
All replies
-
Use the ProcessID to query WMI for the matching process.
\_(ツ)_/
Thursday, October 5, 2017 8:03 PM -
You can also just do this:
get-process -IncludeUserName | Where-Object {$_.WorkingSet -gt 2GB}
\_(ツ)_/
- Marked as answer by Deep_PS Friday, October 6, 2017 6:16 PM
Thursday, October 5, 2017 8:04 PM -
Thanks,I am trying to perform more modifications to the command as per the requirement.
I found out that IncludeUserName parameter does not work when also specifying the -ComputerName parameter:
PS C:\WINDOWS\system32> get-process -IncludeUserName -computerName [ServerName] [ProcessName]| Where-Object {$_.WorkingSet -gt 200MB}
Above command gives error. As per my research, i would have to query WMI.
Is there any other simpler way?.
Friday, October 6, 2017 7:06 PM -
I tried using below command:-
PS C:\WINDOWS\system32> Get-WMIObject -ComputerName [Computer-Class Win32_Process -Filter "Name='[ProcessName]'" | Where-Object {$_.WS -gt 2GB} |Group-Object -Property | select WS,name,@{n='owner';e={$_.getowner().user}}
I am getting output as below:-
WS name owner
-- ---- -----
2572541952 abc.exe user1
2573123584 abc.exe user2
2775318528 abc.exe user3
2871070720 abc.exe user3
6247981056 abc.exe user4For user3 there are two sessions , so its two rows. I want that be summed up and should be shown as 1 row. How do i do grouping considering the above command used.
I want output as below:-
WS name owner
-- ---- -----
2572541952 abc.exe user1
2573123584 abc.exe user2
5646389248 abc.exe user3
6247981056 abc.exe user4
Friday, October 6, 2017 8:27 PM -
Group-Object Owner, Name
Group after the select.
\_(ツ)_/
Friday, October 6, 2017 10:23 PM -
Thanks,I am trying to perform more modifications to the command as per the requirement.
I found out that IncludeUserName parameter does not work when also specifying the -ComputerName parameter:
PS C:\WINDOWS\system32> get-process -IncludeUserName -computerName [ServerName] [ProcessName]| Where-Object {$_.WorkingSet -gt 200MB}
Above command gives error. As per my research, i would have to query WMI.
Is there any other simpler way?.
Sure it does:
Invoke-Command -scriptblock {Get-Process -IncludeUserName} -ComputerName WS702
\_(ツ)_/
Friday, October 6, 2017 10:29 PM