mirror of
https://github.com/coder/coder.git
synced 2026-09-21 12:44:32 +08:00
feat: make username in Initialize.ps1 dynamic (#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.
This commit is contained in:
@@ -64,7 +64,7 @@ $task = @{
|
||||
Action = (New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-sta -ExecutionPolicy Unrestricted -Command "C:\AzureData\CoderAgent.ps1 *>> C:\AzureData\CoderAgent.log"')
|
||||
Trigger = (New-ScheduledTaskTrigger -AtStartup), (New-ScheduledTaskTrigger -Once -At (Get-Date).AddSeconds(15))
|
||||
Settings = (New-ScheduledTaskSettingsSet -DontStopOnIdleEnd -ExecutionTimeLimit ([TimeSpan]::FromDays(3650)) -Compatibility Win8)
|
||||
Principal = (New-ScheduledTaskPrincipal -UserId 'vm\coder' -RunLevel Highest -LogonType S4U)
|
||||
Principal = (New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest -LogonType S4U)
|
||||
}
|
||||
Register-ScheduledTask @task -Force
|
||||
|
||||
|
||||
Reference in New Issue
Block a user