question

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 asked LimitlessTechnology-2700 answered

servicePrincipalName

Hi All

i have a service account lets say svcacct1 and it has serviceprincipalnames. i have 3 requirements.

export the serviceprincipalnames of this svcacct1 to a txt file or csv file. experts guide me

I have a csv with serviceprincipalnames in the below format. i want to delete the below values from svcacct1 how do i delete it be importing the csv file as it has 70 values.

names
http/server1.contoso.com
https/server2.contoso.com

will the below syntax work

$list=import-csv C:\temp\list.csv
ForEach($spn in $list){
setspn -d $spn.names svcacct1
}

i have a csv file with serviceprincipalnames in the below format. how do i add the below values from svcacct1 by importing the text file.

names
http/server3.contoso.com
https/server4.contoso.com


$list=import-csv C:\temp\list.csv
ForEach($spn in $list){
setspn -s $spn.name svcacct1
}

windows-serverwindows-server-powershellwindows-server-2019windows-server-2016
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hello GlennMaxwell,

There is a comprehensive article to define the Principal Names using Set-AdUser:

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ee617215(v=technet.10)?redirectedfrom=MSDN#serviceprincipalnames

Extract:
Syntax:
To add values:
-ServicePrincipalNames @{Add=value1,value2,...}
To remove values:
-ServicePrincipalNames @{Remove=value3,value4,...}
To replace values:
-ServicePrincipalNames @{Replace=value1,value2,...}
To clear all values:
-ServicePrincipalNames $null

You can specify more than one change by using a list separated by semicolons. For example, use the following syntax to add and remove service principal names.
@{Add=value1,value2,...};@{Remove=value3,value4,...}

The operators will be applied in the following sequence:
..Remove
..Add
..Replace



--If the reply is helpful, please Upvote and Accept as answer--

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

You could try this script: powershell-replacement-for-setspn

That link also explains how to remove replace and remove SPNs on an account.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.