pentest-distro-builder/filesystem/etc/skel/.vscode/extensions/ms-vscode.powershell-1.8.4/examples/Stop-Process2.ps1

37 lines
723 B
PowerShell
Raw Normal View History

2018-10-17 14:11:16 -06:00
<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
#>
function Stop-Process2 {
[CmdletBinding(SupportsShouldProcess = $true)]
[Alias()]
[OutputType([int])]
param(
# Param1 help description
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
$Name
)
process {
if ($PSCmdlet.ShouldProcess("")) {
$processes = Get-Process -Name $Name
foreach ($process in $processes) {
$id = $process.Id
$name = $process.Name
Write-Output "Killing $name ($id)"
$process.Kill();
Start-Sleep -Seconds 1
}
}
}
}