Refactor creation of scheduled task action
This commit is contained in:
parent
c3d8e79fcf
commit
03086d1052
1 changed files with 7 additions and 3 deletions
|
@ -47,9 +47,13 @@ function Enable-UACNextLogin() {
|
|||
$propertyName = "EnableLUA";
|
||||
$null = Set-ItemProperty "$keyPath" -Name "$propertyName" -Value 1;
|
||||
|
||||
$action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument ("-c " + `
|
||||
"Set-ItemProperty `"$keyPath`" -Name `"$propertyName`" -Value 0;" + `
|
||||
"Unregister-ScheduledTask -Force $taskName;");
|
||||
$action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument (
|
||||
[string]::Join(
|
||||
" ",
|
||||
@(
|
||||
"-c",
|
||||
"Set-ItemProperty `"$keyPath`" -Name `"$propertyName`" -Value 0;",
|
||||
"Unregister-ScheduledTask -Force $taskName;")));
|
||||
|
||||
$trigger = New-ScheduledTaskTrigger -AtLogOn;
|
||||
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest;
|
||||
|
|
Loading…
Reference in a new issue