23 lines
1.5 KiB
PowerShell
23 lines
1.5 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
Add-LocalGroupMember -Group 'Administrators' -Member 'ACG\svc-msp360' -ErrorAction SilentlyContinue
|
|
Write-Output ('local admin: ' + [bool](Get-LocalGroupMember -Group 'Administrators' -Member 'ACG\svc-msp360' -ErrorAction SilentlyContinue))
|
|
$sid = (New-Object System.Security.Principal.NTAccount('ACG','svc-msp360')).Translate([System.Security.Principal.SecurityIdentifier]).Value
|
|
$tmp = 'C:\Windows\Temp\se.inf'
|
|
secedit /export /cfg $tmp /areas USER_RIGHTS | Out-Null
|
|
$c = Get-Content $tmp
|
|
$line = $c | Where-Object { $_ -match '^SeServiceLogonRight' }
|
|
if ($line -notmatch [regex]::Escape($sid)) {
|
|
$new = $c -replace '^(SeServiceLogonRight *=.*)$', ('$1,*' + $sid)
|
|
if (-not $line) { $new += 'SeServiceLogonRight = *' + $sid }
|
|
$new | Set-Content $tmp -Encoding Unicode
|
|
secedit /configure /db C:\Windows\Temp\se.sdb /cfg $tmp /areas USER_RIGHTS | Out-Null
|
|
Write-Output 'SeServiceLogonRight granted'
|
|
} else { Write-Output 'SeServiceLogonRight already present' }
|
|
Remove-Item $tmp, C:\Windows\Temp\se.sdb -ErrorAction SilentlyContinue
|
|
$svc = Get-WmiObject Win32_Service -Filter "Name='Online Backup Service'"
|
|
$r = $svc.Change($null,$null,$null,$null,$null,$null,'ACG\svc-msp360','Lcyaz0KF5L8IoRh7Pf4K.7QQwJq')
|
|
Write-Output ('service change rc=' + $r.ReturnValue)
|
|
Restart-Service 'Online Backup Service' -Force
|
|
Start-Sleep -Seconds 5
|
|
Get-WmiObject Win32_Service -Filter "Name='Online Backup Service'" | Select-Object Name, StartName, State | Format-Table -AutoSize
|