Skip to content

Instantly share code, notes, and snippets.

@DiHo78
Last active Sep 27, 2020
Embed
What would you like to do?
#SPN SETZEN DB Service
$MeinServiceKto = "MyServiceAccount"
#Variablen fuer Alias, Environment, Dienst
$AliasApp = "MyApp"
$TargetEnv = "P"
$Svc = "MSSQLSvc"
$domain = 'domain.local'
$MeinServiceKonto = $MeinServiceKto + $TargetEnv
$MeinServiceKonto
$DBSPNs2Add = @()
$DBSPNs2Add += $svc+ '/SQL-'+$AliasApp+'-DB-'+$Targetenv+'.'+$domain+':1433' #still a bit static
$DBSPNs2Add += $svc+ '/SQL-'+$AliasApp+'-DB-'+$Targetenv+'.'+$domain #still a bit static
$DBSPNs2Add
$mySvcAcc = Get-ADServiceAccount -Identity $MeinServiceKonto
$mySvcAcc.DistinguishedName
#SPN hinzufügen
Set-ADObject -Identity $mySvcAcc -Add @{"ServicePrincipalName"=$DBSPNs2Add} -Verbose -WhatIf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment