Powershell, Scripting

End a process in powershell

I recently encountered a problem where i wanted to end multiple processes that were running. In my quest to learn powershell I had a look to see if could do it via this method. It was a simple one line cmdlet:

stop-process -name iexplore

Simples!

NAME
    Stop-Process

SYNOPSIS
    Stops one or more running processes.

SYNTAX
    Stop-Process [-Id] <Int32[]> [-Force] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Stop-Process -InputObject <Process[]> [-Force] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Stop-Process -Name <string[]> [-Force] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Stop-Process cmdlet stops one or more running processes. You can specify a process by process name or process ID (PID), or pass a process object to Stop-Process.  Stop-Process works only on processes running on the local computer.

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 youuse the Force parameter.

Be Sociable, Share!