mirror of
https://github.com/kforney/pentest-distro-builder.git
synced 2024-11-25 09:45:25 -07:00
37 lines
723 B
PowerShell
37 lines
723 B
PowerShell
|
<#
|
||
|
.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
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|