PowerShell Helper scripts to manage windows services.
- Copy the files
- Open Command Line or PowerShell (Window + X, A)
- If you opened Command Prompt, then type powershell in order to use PowerShell commands
- Navigate to the scripts directory
cd your_directory
- Type
Import-Module .\ServiceHelper.psm1
- Now you can use the methods from your PowerShell session
- Enable execution policy using PowerShell Admin
Set-ExecutionPolicy Unrestricted
- Navigate to the profile path
cd (Split-Path -parent $PROFILE)
- Open the location in Explorer
ii .
- Create the user profile if it does not exist
If (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
- Import the module in the PowerShell profile
Import-Module -Path script_directory -ErrorAction SilentlyContinue
Get all services that match the specified parameters
Get all services
Get-Services
Get all services with name contains keyword custom
Get-Services -regex '*custom*'
Get all services consuming more than 500MB RAM
Get-Services -ramMB 500
Get all services consuming more than 100 threads
Get-Services -threads 100
Get all services consuming more than 100 threads or 500MB RAM
Get-Services -ramMB 500 -threads 100
Stop all services that match the specified parameters
Stop all services with name contains keyword custom
Stop-Services -regex '*custom*'
Stop all services consuming more than 500MB RAM
Stop-Services -ramMB 500
Stop all services consuming more than 100 threads
Stop-Services -threads 100
Stop all services consuming more than 100 threads or 500MB RAM
Stop-Services -ramMB 500 -threads 100
Restart all services that match the specified parameters
Restart all services with name contains keyword custom
Restart-Services -regex '*custom*'
Restart all services consuming more than 500MB RAM
Restart-Services -ramMB 500
Restart all services consuming more than 100 threads
Restart-Services -threads 100
Restart all services consuming more than 100 threads or 500MB RAM
Restart-Services -ramMB 500 -threads 100