Skip to content

Commit e58f0d0

Browse files
v1.1.0
1 parent 092929e commit e58f0d0

22 files changed

+1737
-1114
lines changed

MemoryTools.psd1

-4.11 KB
Binary file not shown.

MemoryTools.psm1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
2-
31
#import module variables and aliases
4-
. $PSScriptRoot\functions\public.ps1
5-
2+
(Get-Childitem -Path $PSScriptRoot\functions\*.ps1).Foreach({. $_.FullName})
63

74
#global settings for MemoryTools commands
85

@@ -19,7 +16,5 @@ Or modify the file for permanent changes. You will need to
1916
re-import the module for the changes to take effect.
2017
#>
2118

22-
2319
[ValidateRange(1, 100)][int32]$Global:MemoryToolsOK = 45
2420
[ValidateRange(1, 100)][int32]$Global:MemoryToolsWarning = 15
25-

README.md

Lines changed: 79 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
[![PSGallery Version](https://img.shields.io/powershellgallery/v/MemoryTools.png?style=for-the-badge&logo=powershell&label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/MemoryTools/) [![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/MemoryTools.png?style=for-the-badge&label=Downloads)](https://www.powershellgallery.com/packages/MemoryTools/)
44

5-
This module contains a set of PowerShell functions for reporting on computer memory utilization and configuration. The commands use `Get-CimInstance` so remote computers must be running PowerShell 3.0 or later. The project was first described on my [blog](http://bit.ly/1Tooj3Q).
5+
This module contains a set of PowerShell functions for reporting on computer memory utilization and configuration. The commands use `Get-CimInstance`, so PowerShell 3.0 or later must be installed on remote computers, and they need to be configured for PowerShell remoting.
66

7-
Install the latest version of this module from the PowerShell Gallery.
7+
The project was first described on my [blog](http://bit.ly/1Tooj3Q).
8+
9+
Install the latest version of this module from the PowerShell Gallery. It should work in Windows PowerShell 5.1 and PowerShell 7 on a Windows platform.
810

911
```powershell
10-
Install-Module MemoryTools [-scope currentuser]
12+
Install-Module MemoryTools [-scope CurrentUser]
1113
```
1214

1315
## [Get-MemoryUsage](docs/Get-MemoryUsage.md)
@@ -30,11 +32,11 @@ This command will also get the same information as Get-MemoryUsage but will disp
3032

3133
## [Test-MemoryUsage](docs/Test-MemoryUsage.md)
3234

33-
This command can be used to test if memory utilization meets some criteria. There are several parameter sets for different tests. All of them can be used with -Quiet to return a simple Boolean value.
35+
This command can be used to test if memory utilization meets some criteria. There are several parameter sets for different tests. All of them can be used with `-Quiet` to return a simple Boolean value.
3436

3537
### Percent Free
3638

37-
The default behavior is to see is there is at least 50% free memory, but you can specify a different value.
39+
The default behavior is to see if there is at least 50% free memory, but you can specify a different value.
3840

3941
```powershell
4042
PS C:\> Test-MemoryUsage
@@ -162,66 +164,81 @@ Micron 16 SODIMM 2667 1200 ChannelB-DIMM0
162164

163165
## [Get-TopProcessMemory](docs/Get-TopProcessMemory.md)
164166

165-
This command will use `Get-CimInstance` to retrieve the top processes by *Workingset*. It will retrieve the top 5 by default. The output will include a percentage of total in-use memory the process is using as well as the process owner.
167+
This command will use `Get-CimInstance` to retrieve the top processes by *Workingset*. It will retrieve the top 5 by default. The output will include a percentage of the total memory in use and the process owner.
166168

167169
```powershell
168170
PS C:\> Get-TopProcessMemory
169171
170-
Computername : PROSPERO
171-
ProcessID : 20612
172-
Name : firefox.exe
173-
WS(MB) : 1548.55859375
174-
PctUsed : 8.83
175-
CreationDate : 10/26/2020 1:59:02 PM
176-
RunTime : 03:23:47.8689917
177-
Commandline : "C:\Program Files\Mozilla Firefox\firefox.exe" -contentproc
178-
--channel="19336.20.1545159411\236482607" -childID 3
179-
-isForBrowser -prefsHandle 5180 -prefMapHandle 5160 -prefsLen
180-
7680 -prefMapSize 245875 -parentBuildID 20201014125134 -appdir
181-
"C:\Program Files\Mozilla Firefox\browser" - 19336
182-
"\\.\pipe\gecko-crash-server-pipe.19336" 5176 tab
183-
Owner : NT AUTHORITY\NETWORK SERVICE
184-
185-
Computername : PROSPERO
186-
ProcessID : 5204
187-
Name : sqlservr.exe
188-
WS(MB) : 738.671875
189-
PctUsed : 4.21
190-
CreationDate : 10/26/2020 1:56:58 PM
191-
RunTime : 03:25:52.2052364
192-
Commandline : "C:\Program Files\Microsoft SQL
193-
Server\MSSQL15.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -sSQLEXPRESS
194-
Owner : NT AUTHORITY\NETWORK SERVICE
195-
196-
Computername : PROSPERO
197-
ProcessID : 19336
198-
Name : firefox.exe
199-
WS(MB) : 507.62890625
200-
PctUsed : 2.89
201-
CreationDate : 10/26/2020 1:59:00 PM
202-
RunTime : 03:23:49.7282834
203-
Commandline : "C:\Program Files\Mozilla Firefox\firefox.exe"
204-
Owner : NT AUTHORITY\NETWORK SERVICE
205-
206-
Computername : PROSPERO
207-
ProcessID : 5412
208-
Name : Snagit32.exe
209-
WS(MB) : 444.515625
210-
PctUsed : 2.53
211-
CreationDate : 10/26/2020 1:57:47 PM
212-
RunTime : 03:25:02.8728620
213-
Commandline : "C:\Program Files\TechSmith\Snagit 2020\Snagit32.exe" /i
214-
Owner : NT AUTHORITY\NETWORK SERVICE
215-
216-
Computername : PROSPERO
217-
ProcessID : 12556
218-
Name : thunderbird.exe
219-
WS(MB) : 436.14453125
220-
PctUsed : 2.49
221-
CreationDate : 10/26/2020 4:02:00 PM
222-
RunTime : 01:20:50.0968368
223-
Commandline : "C:\Program Files\Mozilla Thunderbird\thunderbird.exe"
224-
Owner : NT AUTHORITY\NETWORK SERVICE
172+
Computername: PROSPERO
173+
174+
ProcessID : 4280
175+
Name : Memory Compression
176+
WS(MB) : 1306.37
177+
PctUsed : 4.9505
178+
Owner : NT AUTHORITY\SYSTEM
179+
Commandline :
180+
181+
ProcessID : 40800
182+
Name : pwsh.exe
183+
WS(MB) : 1250.1
184+
PctUsed : 4.7373
185+
Owner : PROSPERO\Jeff
186+
Commandline : "C:\Program Files\PowerShell\7\pwsh.exe" -nologo
187+
188+
ProcessID : 43612
189+
Name : pwsh.exe
190+
WS(MB) : 534.37
191+
PctUsed : 2.025
192+
Owner : PROSPERO\Jeff
193+
Commandline : "C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile
194+
-ExecutionPolicy Bypass -Command "Import-Module 'c:\Users\Jeff\.vs
195+
code\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEd
196+
itorServices\PowerShellEditorServices.psd1'; Start-EditorServices
197+
-HostName 'Visual Studio Code Host' -HostProfileId
198+
'Microsoft.VSCode' -HostVersion '2023.2.1' -AdditionalModules
199+
@('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users
200+
\Jeff\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules'
201+
-EnableConsoleRepl -StartupBanner '' -LogLevel 'Normal' -LogPath '
202+
c:\Users\Jeff\AppData\Roaming\Code\User\globalStorage\ms-vscode.po
203+
wershell\logs\1679663113-13d77409-f0b9-4af6-87e8-58d6de36834f16796
204+
62816963\EditorServices.log' -SessionDetailsPath 'c:\Users\Jeff\Ap
205+
pData\Roaming\Code\User\globalStorage\ms-vscode.powershell\session
206+
s\PSES-VSCode-29600-898846.json' -FeatureFlags @() "
207+
208+
ProcessID : 13480
209+
Name : PhoneExperienceHost.exe
210+
WS(MB) : 431.92
211+
PctUsed : 1.6368
212+
Owner : PROSPERO\Jeff
213+
Commandline : "C:\Program Files\WindowsApps\Microsoft.YourPhone_1.23022.139.0_x6
214+
4__8wekyb3d8bbwe\PhoneExperienceHost.exe"
215+
-Restart:{F534506B-042E-4975-BF2C-806D54F0EBC7}
216+
217+
ProcessID : 31184
218+
Name : firefox.exe
219+
WS(MB) : 349.93
220+
PctUsed : 1.3261
221+
Owner : PROSPERO\Jeff
222+
Commandline : "C:\Program Files\Mozilla Firefox\firefox.exe" -osint -url
223+
https://pester.dev/docs/commands/Should
225224
```
226225

227-
Last updated _2020-11-11 23:00:59Z_
226+
## [Get-ProcessMemory](docs/Get-ProcessMemory.md)
227+
228+
Get a snapshot of a process' memory usage based on its workingset value. Processes are grouped by name.
229+
230+
```powershell
231+
PS C:\> Get-ProcessMemory | Select-Object -first 5
232+
233+
Name Count Threads AvgMB SumMB Computername
234+
---- ----- ------- ----- ----- ------------
235+
firefox 17 467 142.2585 2418.3945 PROSPERO
236+
pwsh 3 101 642.0807 1926.2422 PROSPERO
237+
svchost 102 692 16.0955 1641.7461 PROSPERO
238+
Code 13 264 117.466 1527.0586 PROSPERO
239+
Memory Compression 1 54 1306.3555 1306.3555 PROSPERO
240+
```
241+
242+
## Roadmap
243+
244+
I have plans to revise commands to take advantage of SSH remoting in PowerShell 7. It also might be nice to have a WPF-based GUI to display memory information.

0 commit comments

Comments
 (0)