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";
|
$propertyName = "EnableLUA";
|
||||||
$null = Set-ItemProperty "$keyPath" -Name "$propertyName" -Value 1;
|
$null = Set-ItemProperty "$keyPath" -Name "$propertyName" -Value 1;
|
||||||
|
|
||||||
$action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument ("-c " + `
|
$action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument (
|
||||||
"Set-ItemProperty `"$keyPath`" -Name `"$propertyName`" -Value 0;" + `
|
[string]::Join(
|
||||||
"Unregister-ScheduledTask -Force $taskName;");
|
" ",
|
||||||
|
@(
|
||||||
|
"-c",
|
||||||
|
"Set-ItemProperty `"$keyPath`" -Name `"$propertyName`" -Value 0;",
|
||||||
|
"Unregister-ScheduledTask -Force $taskName;")));
|
||||||
|
|
||||||
$trigger = New-ScheduledTaskTrigger -AtLogOn;
|
$trigger = New-ScheduledTaskTrigger -AtLogOn;
|
||||||
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest;
|
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest;
|
||||||
|
|
Loading…
Reference in a new issue