From 5d914ce33f3a3e0d40865c38addc3c256106276a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 22 Mar 2024 18:28:37 +0100 Subject: [PATCH] Refactor the creation of scheduled tasks --- scripts/Windows/OS/User/Add.ps1 | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/Windows/OS/User/Add.ps1 b/scripts/Windows/OS/User/Add.ps1 index 301e04c7..58746a8f 100644 --- a/scripts/Windows/OS/User/Add.ps1 +++ b/scripts/Windows/OS/User/Add.ps1 @@ -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 (