Notification

Icon
Error

PowerShell - Top 10 Memory Hogs - Custom Action to get the Current Top 10 Memory Hogs on a PC

Posted: Tuesday, February 18, 2020 9:05:31 PM(UTC)
ZippoManOnFire

ZippoManOnFire

Member Original PosterPosts: 2
1
Like
I needed a quick way to get the top 10 Memory Hogs on a PC. This Command will open up Powershell on your computer and show you the top 10 Memory Hogs on the Remote PC. It pauses at the end to keep the Window Open.

powershell.exe Invoke-Command -ComputerName {smartname} {Get-Process |Sort-Object -Descending WorkingSet |Select-Object -first 10 Name,ID,@{Name='WorkingSet';Expression={[math]::Round($_.WorkingSet/1KB,2)}} |FT Name,@{L='PID';E={$_.id}},@{L='Memory';E={$_.workingset}};Pause}
ZippoManOnFire
#1ZippoManOnFire Member Original PosterPosts: 2  
posted: 2/19/2020 9:54:07 PM(UTC)
If the Pause at the end gives you pause, I came up with an alternative using cmd.exe /K. I also added an Echo at the beginning so you can see which computer it is being run against.

Code:
cmd.exe /K powershell.exe "echo '{smartname}';Invoke-Command -ComputerName {smartname} {Get-Process |Sort-Object -Descending WorkingSet |Select-Object -first 10 Name,ID,@{Name='WorkingSet';Expression={[math]::Round($_.WorkingSet/1KB,2)}} |FT Name,@{L='PID';E={$_.id}},@{L='Memory';E={$_.workingset}}}"
iamBaphomet
#2iamBaphomet Member Posts: 1  
posted: 2/21/2020 3:00:53 PM(UTC)
Thank you for this, much appreciated Applause

Active Discussions

Lansweeper Close ticket failed
by  JohnnyL   Go to last post Go to first unread
Last post: Yesterday at 6:51:21 PM(UTC)
Lansweeper SNMP Asset dont work
by  implenia  
Go to last post Go to first unread
Last post: Yesterday at 3:44:02 PM(UTC)
Lansweeper Remote IT Asset MGMT during the Covid-19 Crisis
by  Esben.D   Go to last post Go to first unread
Last post: Yesterday at 1:14:27 PM(UTC)
Lansweeper Unable to transfer user's data prior to removal
by  jbruyet  
Go to last post Go to first unread
Last post: 4/1/2020 11:40:35 PM(UTC)
Lansweeper Scanning IP Range Subnet
by  ethanthekiwi   Go to last post Go to first unread
Last post: 4/1/2020 9:16:35 PM(UTC)
Lansweeper Toner Levels Missing
by  brodiemac-too  
Go to last post Go to first unread
Last post: 4/1/2020 8:42:19 PM(UTC)
Lansweeper WLC 5508 question
by  Faktotum   Go to last post Go to first unread
Last post: 4/1/2020 1:10:23 PM(UTC)
Lansweeper SNMPv3 global credentials ?
by  JeremySG  
Go to last post Go to first unread
Last post: 4/1/2020 9:01:16 AM(UTC)