-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
folder-unwatcher.ps1
27 lines (21 loc) · 913 Bytes
/
folder-unwatcher.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
$selection = Get-EventSubscriber
if($selection.Count -gt 1){
$title = "Event Selection"
$message = "Which event would you like to unsubscribe from?"
$choices = @()
for($index = 0; $index -lt $selection.Count; $index++){
$choices += New-Object System.Management.Automation.Host.ChoiceDescription ($selection[$index].SourceIdentifier),($selection[$index].SourceIdentifier)
}
$choices += New-Object System.Management.Automation.Host.ChoiceDescription "All","Delete All Events"
$options = [System.Management.Automation.Host.ChoiceDescription[]]$choices
$result = $host.UI.PromptForChoice($title, $message, $options, 0)
if($result -eq $selection.count){
$selection = $selection
} else {
$selection = $selection[$result]
}
}
foreach($evt in $selection){
Write-Host "$evt.SourceIdentifier removed"
Unregister-Event $evt.SourceIdentifier
}