PowerShell Genie

Microsoft.PowerShell.Management module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Use core management cmdlets for services, processes, files and computers, and verify object types before filtering or formatting output.

Getting it

Built into every PowerShell edition on every platform, with no import step needed.

Examples

1PS> Get-Service
Show reference output
1 Name Status StartType DisplayName
2 -------- ------- --------- ---------------------------------------
3 BITS Running Manual Background Intelligent Transfer Service
4 Dnscache Running Automatic DNS Client
5 EventLog Running Automatic Windows Event Log
6 Spooler Running Automatic Print Spooler
7 W32Time Running Manual Windows Time
8 WinRM Stopped Manual Windows Remote Management
9 wuauserv Running Manual Windows Update
1PS> Get-Process | Where-Object CPU -gt 20
Show reference output
1 Name ProcessName Id CPU WS
2 ------- ----------- ---- ------ ---------
3 chrome chrome 9184 842.31 486539264
4 MsMpEng MsMpEng 2600 950 220200960

What it is for

Reach for it when a task involves paths, service state, or a running process. It also owns the registry provider, so anything under HKLM: or HKCU: goes through Get-ItemProperty and Set-ItemProperty here rather than through a separate module.

Typical tasks

  • Enumerate files by age or size
  • Query and control Windows service state
  • Read and write registry values
  • Inspect running processes and their image paths
  • Copy content between two providers
  • Test whether a path exists before acting on it

Check the installed version

1PS> Get-Module -ListAvailable Microsoft.PowerShell.Management | Select-Object Name, Version, Path
2PS> Get-Command -Module Microsoft.PowerShell.Management

Compare the module path and version with the session used by your scheduled task or automation account. Reach for it when a task involves paths, service state, or a running process. It also owns the registry provider, so anything under HKLM: or HKCU: goes through Get-ItemProperty and Set-ItemProperty here rather than through a separate module.

Primary documentation

Get-ChildItem reference · Where-Object reference · Get-Process reference

Continue
Genie guideMicrosoft.PowerShell.Management module: setup and commands

Use core management cmdlets for services, processes, files and computers, and verify object types before filtering or formatting output.