fix(agent): add --hostname support to Windows PowerShell install script

Adds $Hostname / $env:PULSE_HOSTNAME parameter so users can set a
custom display name at install time, matching the Linux install.sh
behaviour. Persists to config.json and passes --hostname to the agent
binary args.

Closes discussion #818
This commit is contained in:
rcourtman 2026-03-13 11:54:12 +00:00
parent e137f3fbf7
commit 6b317f08d2

View file

@ -11,6 +11,7 @@ param(
[string]$PulseUrl = $env:PULSE_URL,
[string]$Token = $env:PULSE_TOKEN,
[string]$Interval = $env:PULSE_INTERVAL,
[string]$Hostname = $env:PULSE_HOSTNAME,
[string]$InstallPath = "C:\Program Files\Pulse",
[string]$Arch = $env:PULSE_ARCH,
[switch]$NoService
@ -253,6 +254,9 @@ PulseInfo "Configuration:"
Write-Host " Pulse URL: $PulseUrl"
Write-Host " Token: $(if ($Token) { '***' + $Token.Substring([Math]::Max(0, $Token.Length - 4)) } else { 'none' })"
Write-Host " Interval: $Interval"
if ($Hostname) {
Write-Host " Hostname Override: $Hostname"
}
Write-Host " Install Path: $InstallPath"
if ($Arch) {
Write-Host " Architecture Override: $Arch"
@ -382,6 +386,9 @@ try {
if ($Token) {
$agentArgs += @("--token", "`"$Token`"")
}
if ($Hostname) {
$agentArgs += @("--hostname", "`"$Hostname`"")
}
$serviceBinaryPath = "`"$agentPath`" $($agentArgs -join ' ')"
$manualCommand = "& `"$agentPath`" $($agentArgs -join ' ')"
} catch {
@ -398,6 +405,9 @@ $config = @{
if ($Token) {
$config.token = $Token
}
if ($Hostname) {
$config.hostname = $Hostname
}
$config | ConvertTo-Json | Set-Content $configPath
PulseSuccess "Created configuration at $configPath"