-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStop-WT.ps1
44 lines (41 loc) · 960 Bytes
/
Stop-WT.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function Stop-WT
{
<#
.Synopsis
Stops Windows Terminal
.Description
Stops Windows Terminal Processes
.Link
Start-WT
.Link
Stop-Process
.Example
Stop-WT
#>
[CmdletBinding(SupportsShouldProcess,DefaultParameterSetName='All')]
[OutputType([Nullable])]
param(
# The Process ID
[Parameter(Mandatory,ParameterSetName='ProcessID',ValueFromPipelineByPropertyName)]
[Alias('PID', 'ProcessID')]
[int[]]
$ID
)
begin {
$allIds = [Collections.ArrayList]::new()
}
process {
$allIds.AddRange($ID)
}
end {
#region Stop Terminals
@(if (-not $allIds) {
Get-Process WindowsTerminal -ErrorAction Ignore
} else {
Get-Process WindowsTerminal -ErrorAction Ignore |
Where-Object ID -In $allIds
}) |
Stop-Process
#endregion Stop Terminals
}
}