fix: preserve user access to managed agent pipe after migration

This commit is contained in:
tongtong committed 2026-11-12 22:09:45 +08:00
1 parent 1913984f80
commit 8ecfe880cc
2 files changed
+7

No files matched your search

+5
View File
@@ -37,6 +37,11 @@ try {
$next | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $configPath -Encoding utf8NoBOM
& $ctl --config $configPath config validate --file $configPath
if ($LASTEXITCODE) { throw 'Managed config validation failed' }
# Elevated directory creation may set Administrators as owner. The pipe ACL
# follows this owner, so use the actual installing account rather than its group.
$directoryAcl = Get-Acl -LiteralPath $root
$directoryAcl.SetOwner([System.Security.Principal.WindowsIdentity]::GetCurrent().User)
Set-Acl -LiteralPath $root -AclObject $directoryAcl
& $ctl --config $configPath service install
if ($LASTEXITCODE) { throw 'Managed service installation failed' }
$ready=$false