-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Clear-EventSource.ps1
37 lines (36 loc) · 1008 Bytes
/
Clear-EventSource.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
function Clear-EventSource
{
<#
.Synopsis
Clears event source subscriptions
.Description
Clears any active subscriptions for any event source.
.Example
Clear-EventSource
.Link
Get-EventSource
#>
[CmdletBinding(SupportsShouldProcess=$true)]
[OutputType([nullable])]
param(
# The name of the event source.
[Parameter(ValueFromPipelineByPropertyName)]
[string[]]
$Name)
process {
#region Determine Event Sources
$parameterCopy = @{} + $PSBoundParameters
$null = $parameterCopy.Remove('WhatIf')
$eventSources = Get-EventSource @parameterCopy -Subscription
if ($WhatIfPreference) {
$eventSources
return
}
#endregion Determine Event Sources
#region Unregister
if ($PSCmdlet.ShouldProcess("Clear event sources $($Name -join ',')")) {
$eventSources | Unregister-Event
}
#endregion Unregister
}
}