From e70ce7f0dc0dd35f9ad985633f521ffc0e36f0a2 Mon Sep 17 00:00:00 2001 From: heqnx Date: Mon, 14 Jul 2025 20:11:47 +0300 Subject: added mssql02 linked to websql01 --- ansible/scripts/populate-ad.ps1 | 18 ++++++++++++++---- ansible/scripts/setup-websql.ps1 | 3 +-- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'ansible/scripts') 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" { diff --git a/ansible/scripts/setup-websql.ps1 b/ansible/scripts/setup-websql.ps1 index 02e370b..7881291 100644 --- a/ansible/scripts/setup-websql.ps1 +++ b/ansible/scripts/setup-websql.ps1 @@ -1,7 +1,6 @@ param ( [string]$DomainName = "contoso.com", - #[string]$SvcUsername = "svc_websql01", - [string]$SvcUsername = "svc_mssql02", + [string]$SvcUsername = "svc_websql01", [string]$SvcPassword = "Svc1234!" ) -- cgit v1.2.3