summaryrefslogtreecommitdiff
path: root/ansible/scripts/populate-ad.ps1
diff options
context:
space:
mode:
authorheqnx <root@heqnx.com>2025-07-14 20:11:47 +0300
committerheqnx <root@heqnx.com>2025-07-14 20:11:47 +0300
commite70ce7f0dc0dd35f9ad985633f521ffc0e36f0a2 (patch)
treec897782e27ddb84faf80b7030509fafa3466d3d2 /ansible/scripts/populate-ad.ps1
parent116a86865e3f0636bf5821e066d9b6956f0363e0 (diff)
downloadansible-active-directory-range-e70ce7f0dc0dd35f9ad985633f521ffc0e36f0a2.tar.gz
ansible-active-directory-range-e70ce7f0dc0dd35f9ad985633f521ffc0e36f0a2.zip
added mssql02 linked to websql01
Diffstat (limited to 'ansible/scripts/populate-ad.ps1')
-rw-r--r--ansible/scripts/populate-ad.ps118
1 files changed, 14 insertions, 4 deletions
diff --git a/ansible/scripts/populate-ad.ps1 b/ansible/scripts/populate-ad.ps1
index 17801e0..3d8917a 100644
--- a/ansible/scripts/populate-ad.ps1
+++ b/ansible/scripts/populate-ad.ps1
@@ -125,6 +125,7 @@ Write-Host "[inf] Created computers: $($created_computers -Join ', ')"
$svc_users = @{
"svc_mssql01" = @{"type" = "spn"; "value" = "MSSQLSVC"}
"svc_mssql02" = @{"type" = "spn"; "value" = "MSSQLSVC"}
+ "svc_websql01" = @{"type" = "spn"; "value" = @("MSSQLSVC", "HTTP")}
"svc_cifs01" = @{"type" = "spn"; "value" = "CIFS"}
"svc_cifs02" = @{"type" = "spn"; "value" = "CIFS"}
"svc_iis01" = @{"type" = "spn"; "value" = "HTTP"}
@@ -161,12 +162,21 @@ ForEach ($user in $svc_users.keys) {
-Enabled $true `
-PasswordNeverExpires $true `
-PassThru
- Set-ADUser -Identity "$u" -ServicePrincipalNames @{Add="$value/$comp"}
- Set-ADObject $u -Description "SPN on $value/$comp"
- $created_svc_users += "$user ($value/$comp)"
+ $spns = @()
+ if ($value -is [string]) {
+ $spns += "$value/$comp"
+ } else {
+ foreach ($v in $value) {
+ $spns += "$v/$comp"
+ }
+ }
+
+ Set-ADUser -Identity "$u" -ServicePrincipalNames @{Add=$spns}
+ Set-ADObject $u -Description ("SPNs: " + ($spns -join ", "))
+ $created_svc_users += "$user ($($spns -join ', '))"
} catch {
- Write-Host "[err] Failed to create $value/$comp for $user"
+ Write-Host "[err] Failed to create SPNs for $user"
}
}
"group" {