Files
Sandbox/Cohesity-ServiceRunAs.ps1
Zack Meier 03dba08135 sync
2026-04-15 15:42:41 -05:00

21 lines
855 B
PowerShell

#Add to Local Security Policy
function Add-ServiceLogonRight([string] $Username) {
Write-Host "Enable ServiceLogonRight for $Username"
$tmp = New-TemporaryFile
secedit /export /cfg "$tmp.inf" | Out-Null
(Get-Content -Encoding ascii "$tmp.inf") -replace '^SeServiceLogonRight .+', "`$0,$Username" | sc -Encoding ascii "$tmp.inf"
secedit /import /cfg "$tmp.inf" /db "$tmp.sdb" | Out-Null
secedit /configure /db "$tmp.sdb" /cfg "$tmp.inf" | Out-Null
Remove-Item $tmp* -ea 0
}
Add-ServiceLogonRight -Username svccohesitysql
# Set Service to Run as Service Account
Stop-Service -Name CohesityAgent
sc.exe config "CohesityAgent" obj="NDGOV\svccohesitysql" password="radiant-yx8aHMrGtc"
Start-Service -Name CohesityAgent
# Add to Local Administrators group
Add-LocalGroupMember -Group Administrators -Member "ndgov\svccohesitysql"