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 Remote desktop custom port
by  sefaucher   Go to last post Go to first unread
Last post: Yesterday at 10:30:49 PM(UTC)
Lansweeper Unable to transfer user's data prior to removal
by  RickW99456  
Go to last post Go to first unread
Last post: Yesterday at 9:06:14 PM(UTC)
Lansweeper Unable to access the lansweeper consol for other computer
by  Kudnan Ingle   Go to last post Go to first unread
Last post: Yesterday at 7:49:32 PM(UTC)
Lansweeper Closing and re-opening of tickets
by  NWHiker  
Go to last post Go to first unread
Last post: Yesterday at 3:42:56 PM(UTC)
Lansweeper Wake on Lan Issues
by  woldummy   Go to last post Go to first unread
Last post: Yesterday at 3:42:07 PM(UTC)
Lansweeper Deploy and start Software
by  EDV_OHZ  
Go to last post Go to first unread
Last post: Yesterday at 12:49:08 PM(UTC)
Lansweeper Helpdek Call Re-Opened
by  mouaad   Go to last post Go to first unread
Last post: Yesterday at 7:30:59 AM(UTC)
Lansweeper macOS lsAgent 100% CPU Usage
by  McDeth187  
Go to last post Go to first unread
Last post: Yesterday at 2:30:33 AM(UTC)