I have to populate a list of AD Computer objects with a backedup array of SPNs from a csv
the csv is in the form of:
name,ServicePrincipalName host1,SPN#1;SPN#2;SPN#3; etc
How can I script the setting of these SPNs?
Thank you,
I have to populate a list of AD Computer objects with a backedup array of SPNs from a csv
the csv is in the form of:
name,ServicePrincipalName host1,SPN#1;SPN#2;SPN#3; etc
How can I script the setting of these SPNs?
Thank you,
Just parse the file, address those semi colon for the SPN collection and loop thru your list while use setspn.exe.
# Create SPNs for target hosts ('host00','host01','host03') | % { setspn -s "SPN#1/$_ $env:USERDOMAIN\$env:USERNAME" setspn -s "SPN#2/$_ $env:USERDOMAIN\$env:USERNAME" setspn -s "SPN#3/$_ $env:USERDOMAIN\$env:USERNAME" } # View SPN's of target hosts ('host00','host01','host03') | % { setspn -L $_ }
If you are saying that SPN collection is unknown then something like this normal parse/split and loop.
$SPNList = Import-Csv -Path 'D:\Scripts\SPNList.csv' ForEacH ($SPNTarget in $SPNList) { "Processing SPNs for $($SPNTarget.Name)" ForEach($SPNName in ($SPNTarget.ServicePrincipalName -split ';')) { setspn -s "$SPNName/$($SPNTarget.Name) $env:USERDOMAIN\$env:USERNAME" } }
I can’t test the above right now.
thank you postanote
No worries