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 Scan User Exclusion / Define User OU for active scanning
by  Almada   Go to last post Go to first unread
Last post: 9/17/2021 6:43:34 PM(UTC)
Lansweeper sqlServerId is changing
by  Ciro Bizelli  
Go to last post Go to first unread
Last post: 9/17/2021 3:40:34 PM(UTC)
Lansweeper Slow Loading Lansweeper
by  Maikel Vanroelen   Go to last post Go to first unread
Last post: 9/17/2021 9:25:31 AM(UTC)
Lansweeper Sync information
by  Jay-IT  
Go to last post Go to first unread
Last post: 9/16/2021 9:20:11 PM(UTC)
Lansweeper "Unknown" exclusion does not exclude Unknown assets
by  Almada   Go to last post Go to first unread
Last post: 9/16/2021 7:18:43 PM(UTC)
Lansweeper multiple scanning servers with granular permission
by  FrankSc  
Go to last post Go to first unread
Last post: 9/16/2021 6:29:54 PM(UTC)
Lansweeper Separate helpdesk websites?
by  JCochran   Go to last post Go to first unread
Last post: 9/15/2021 2:51:03 PM(UTC)
Lansweeper Remove Ads
by  FrankSc  
Go to last post Go to first unread
Last post: 9/15/2021 12:30:18 PM(UTC)