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 Find machines missing any 1 of several apps
by  BennettL   Go to last post Go to first unread
Last post: Yesterday at 8:35:28 PM(UTC)
Lansweeper Max Software Version and Deploy to Only Outdated
by  GenDev   Go to last post Go to first unread
Last post: Yesterday at 1:06:50 PM(UTC)
Lansweeper Patch Tuesday - Superseded MS Updates
by  doone128  
Go to last post Go to first unread
Last post: Yesterday at 11:27:10 AM(UTC)
Lansweeper Report on basic Router information
by  Liljack  
Go to last post Go to first unread
Last post: 3/30/2020 7:44:22 AM(UTC)
Lansweeper Windows: Static IP address configured (Built-in)
by  RobinPSU   Go to last post Go to first unread
Last post: 3/27/2020 8:52:12 PM(UTC)
Lansweeper Adding top user to asset report
by  Argon0  
Go to last post Go to first unread
Last post: 3/26/2020 5:20:51 PM(UTC)