-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_jenkins_service.txt
22 lines (18 loc) · 1.13 KB
/
install_jenkins_service.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$username = "domain\user"
# prepare user profile in GPO
$sid = ((New-Object System.Security.Principal.NTAccount($username)).Translate([System.Security.Principal.SecurityIdentifier])).Value
secedit /export /cfg "export.inf"
$sids = (Select-String "export.inf" -Pattern "SeServiceLogonRight").Line
foreach ($line in @("[Unicode]", "Unicode=yes", "[System Access]", "[Event Audit]", "[Registry Values]", "[Version]", "signature=`"`$CHICAGO$`"", "Revision=1", "[Profile Description]", "Description=GrantLogOnAsAService security template", "[Privilege Rights]", "SeServiceLogonRight = *$sids,*$sid")){
Add-Content "import.inf" $line
}
secedit /import /db "secedt.sdb" /cfg "import.inf"
secedit /configure /db "secedt.sdb"
Remove-Item -Path "import.inf" -Force
Remove-Item -Path "export.inf" -Force
Remove-Item -Path "secedt.sdb" -Force
gpupdate /force
# configure jenkins slave service
sc.exe config "jenkinsslave-c__jenkins_azure" obj="$username" password="$password"
sc.exe failure "jenkinsslave-c__jenkins_azure" reset=360 actions=restart/180000
Restart-Service -Name "jenkinsslave-c__jenkins_azure" ; Get-Service "jenkinsslave-c__jenkins_azure"