In
PowerShell, the Stop-Process cmdlet is used to stop one or more running
processes on a Windows system. The syntax for the Stop-Process cmdlet is as
follows:
Stop-Process [-Name] <String[]> [-Force] [-WhatIf] [-Confirm] [-PassThru] [-ErrorAction <ActionPreference>] [-WarningAction <ActionPreference>] [-InformationAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]
Where,
- -Name: Specifies the name of the process or processes to be stopped. This can be a single process name or an array of process names.
- -Force: Specifies that the process should be forcibly terminated. This can result in data loss or other issues, so use with caution.
- -WhatIf: Specifies that the cmdlet should not actually stop any processes, but instead show what would happen if the cmdlet were to run.
- -Confirm: Prompts the user to confirm before stopping any processes.
- -PassThru: Specifies that the cmdlet should return an object representing the stopped process or processes.
- -ErrorAction, -WarningAction, -InformationAction: Specifies how the cmdlet should handle error, warning, and information messages.
- -ErrorVariable, -WarningVariable, -OutVariable: Specifies variables to which error, warning, and output messages should be redirected.
- -OutBuffer: Specifies the number of objects to buffer before sending them to the next cmdlet.
For example, to stop a process named "notepad.exe", the following command could be used:
Stop-Process -Name notepad.exe
This would stop all instances of the "notepad.exe" process currently running on the system. If multiple instances of the process were running, the cmdlet would stop all of them. If the -PassThru parameter were also specified, the cmdlet would return an object representing the stopped process or processes.