diff --git a/scripts/Common/Scripts/Operations.ps1 b/scripts/Common/Scripts/Operations.ps1 index 3381a2a7..cd41f864 100644 --- a/scripts/Common/Scripts/Operations.ps1 +++ b/scripts/Common/Scripts/Operations.ps1 @@ -4,6 +4,7 @@ $null = New-Module { . "$PSScriptRoot/../Types/OneShotTask.ps1"; + $oneShotTaskName = "PortValhalla OneShot"; $logName = "Application"; $oneShotTrigger = 1337; $taskOption = "OneShotTask"; @@ -50,10 +51,18 @@ $null = New-Module { $trigger = (Get-ScheduledTask $tempTask).Triggers; $principal = New-ScheduledTaskPrincipal -UserId (Get-SetupUser) -RunLevel Highest; $task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger; - $null = Register-ScheduledTask -Force "PortValhalla OneShot" -InputObject $task; + $null = Register-ScheduledTask -Force $oneShotTaskName -InputObject $task; $null = Unregister-ScheduledTask -Confirm:$false $tempTask; } + <# + .SYNOPSIS + Removes the OneShot task. + #> + function Disable-OneShotListener { + Unregister-ScheduledTask -Confirm:$false $oneShotTaskName; + } + <# .SYNOPSIS Invokes a one-shot task.