24

I'm a powershell newbie, but I often find myself starting and stopping a small group of services when I'm debugging some code. In Powershell I can easily stop the processes using a wildcard but it makes me confirm. There is a -confirm parameter, but I must not be using it correctly?

`Stop-Process -ProcessName alcore.* -Confirm`

Can I bypass the confirm and just stop the process?

Thanks for any help, ~ck in San Diego

Hcabnettek
  • 12,678
  • 38
  • 124
  • 190

4 Answers4

35

Try

stop-process -ProcessName alcore.* -Force

From get-help stop-process:

On Windows Vista and later versions of Windows, to stop a process that is not owned by the current user, you must start Windows PowerShell with the "Run as administrator" option. Also, you are prompted for confirmation unless you use the Force parameter.

driis
  • 161,458
  • 45
  • 265
  • 341
3

-Confirm:$false is correct and works for all PS confirmation prompts.

3

-Confirm:$false

STO
  • 10,390
  • 8
  • 32
  • 32
  • 4
    actually this doesn't work: ```[server]: PS C:\Users\user\Documents> Stop-Process -Name python -Confirm:$false``` still prompts me: ```Confirm Are you sure you want to perform the Stop-Process operation on the following item: python(248)? [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): ``` – Thomas BDX Oct 05 '17 at 13:31
  • 1
    Right. This _should_ work, but it doesn't. You have to pass `-Force`. Not sure if this is a bug or intended. – luckman212 May 14 '20 at 14:44
3

If you don't want it to do a confirmation then don't use the -confirm option but instead the -force. Doing this will cause the process to be stopped without any user confirmation.

kill -force outlook

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454