Refactor the creation of scheduled tasks

This commit is contained in:
Manuel Thalmann 2024-03-22 18:28:37 +01:00
parent 24febb32f8
commit 5d914ce33f

View file

@ -83,11 +83,33 @@ function Enable-UACNextLogin([Context] $context) {
[System.Tuple]::Create(
$autoLoginTrigger,
$autoLoginName,
"Invoke-Command { $((Get-AutoLoginScript)) } -ArgumentList @($autoLoginTrigger, '$contextScript', '$preparedUsernameProperty', '$preparedPasswordProperty')")
[string]::Join(
"`n",
@(
"{",
" Invoke-Command { $((Get-AutoLoginScript)) } -ArgumentList @(",
" $autoLoginTrigger,",
" '$contextScript',",
" '$preparedUsernameProperty',",
" '$preparedPasswordProperty'",
" )",
"}")))
[System.Tuple]::Create(
$uacDisablerTrigger,
$uacDisablerName,
"Invoke-Command { $((Get-UACDisablerScript)) } -ArgumentList @($uacDisablerTrigger, '$contextScript', '$autoLoginName', '$uacDisablerName', '$autoLoginTriggerProperty', '$uacDisablerTriggerProperty')"));
[string]::Join(
"`n",
@(
"{",
" Invoke-Command { $((Get-UACDisablerScript)) } -ArgumentList @(",
" $uacDisablerTrigger,",
" '$contextScript',",
" '$autoLoginName',",
" '$uacDisablerName',",
" '$autoLoginTriggerProperty',",
" '$uacDisablerTriggerProperty'",
" )",
"}"))));
foreach ($options in $optionCollection) {
$action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument (