Functions/Stop-ProcessSoft.ps1
function Stop-ProcessSoft { [CmdletBinding()] param ( [Parameter(Mandatory)] [ArgumentCompleter( { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters ) Get-Process "$wordToComplete*" | ForEach-Object { $_.Name } } )] [string] $ProcessName ) if(!(Get-Process $ProcessName -ErrorAction 0)) { Write-Warning "Process $($ProcessName) not found" } else { 1..100 | ForEach-Object { $Process = (Get-Process $ProcessName -ErrorAction 0) if($Process) { $Process.CloseMainWindow() | Out-Null } } } } |