Skip to content

Commit 9fe71d9

Browse files
authored
feat: make username in Initialize.ps1 dynamic (coder#15751)
This PR switches the `UserId` from a constant to a generated values based on the script environment. This enables users to rename their machine and default user name without having to edit this element as well.
1 parent bae12e1 commit 9fe71d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/templates/azure-windows/Initialize.ps1.tftpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ $task = @{
6464
Action = (New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-sta -ExecutionPolicy Unrestricted -Command "C:\AzureData\CoderAgent.ps1 *>> C:\AzureData\CoderAgent.log"')
6565
Trigger = (New-ScheduledTaskTrigger -AtStartup), (New-ScheduledTaskTrigger -Once -At (Get-Date).AddSeconds(15))
6666
Settings = (New-ScheduledTaskSettingsSet -DontStopOnIdleEnd -ExecutionTimeLimit ([TimeSpan]::FromDays(3650)) -Compatibility Win8)
67-
Principal = (New-ScheduledTaskPrincipal -UserId 'vm\coder' -RunLevel Highest -LogonType S4U)
67+
Principal = (New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest -LogonType S4U)
6868
}
6969
Register-ScheduledTask @task -Force
7070

0 commit comments

Comments
 (0)