Skip to content

Commit 560c508

Browse files
authored
Merge pull request #6750 from Xelu86/setspnnew
[NEW] SetSPN command line reference
2 parents e98553e + 0528fcd commit 560c508

File tree

3 files changed

+146
-17
lines changed

3 files changed

+146
-17
lines changed

WindowsServerDocs/administration/windows-commands/TOC.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@
413413
- name: dfsrmig
414414
href: dfsrmig.md
415415
- name: dfsutil
416-
href: dfsutil.md
416+
href: dfsutil.md
417417
- name: diantz
418418
href: diantz.md
419419
- name: dir
@@ -425,12 +425,12 @@
425425
- name: diskpart
426426
href: diskpart.md
427427
- name: diskpart scripts and examples
428-
href: diskpart-scripts-and-examples.md
428+
href: diskpart-scripts-and-examples.md
429429
items:
430430
- name: active
431431
href: active.md
432432
- name: add
433-
href: add_2.md
433+
href: add_2.md
434434
- name: assign
435435
href: assign.md
436436
- name: attach vdisk
@@ -443,16 +443,16 @@
443443
- name: attributes volume
444444
href: attributes-volume.md
445445
- name: automount
446-
href: automount.md
446+
href: automount.md
447447
- name: break
448-
href: break.md
448+
href: break.md
449449
- name: clean
450450
href: clean.md
451451
- name: compact vdisk
452452
href: compact-vdisk.md
453453
- name: convert
454454
href: convert.md
455-
items:
455+
items:
456456
- name: convert basic
457457
href: convert-basic.md
458458
- name: convert dynamic
@@ -512,8 +512,8 @@
512512
href: extend.md
513513
- name: filesystems
514514
href: filesystems.md
515-
- name: format
516-
href: format.md
515+
- name: format
516+
href: format.md
517517
- name: gpt
518518
href: gpt.md
519519
- name: import
@@ -526,7 +526,7 @@
526526
href: merge-vdisk.md
527527
- name: offline
528528
href: offline.md
529-
items:
529+
items:
530530
- name: offline disk
531531
href: offline-disk.md
532532
- name: offline volume
@@ -568,7 +568,7 @@
568568
- name: shrink
569569
href: shrink.md
570570
- name: uniqueid
571-
href: uniqueid.md
571+
href: uniqueid.md
572572
- name: diskperf
573573
href: diskperf.md
574574
- name: diskraid
@@ -582,7 +582,7 @@
582582
- name: add alias
583583
href: add-alias.md
584584
- name: add volume
585-
href: add-volume.md
585+
href: add-volume.md
586586
- name: begin backup
587587
href: begin-backup.md
588588
- name: begin restore
@@ -623,7 +623,7 @@
623623
- name: reset session
624624
href: reset-session.md
625625
- name: revert
626-
href: revert.md
626+
href: revert.md
627627
- name: set
628628
href: set.md
629629
items:
@@ -636,7 +636,7 @@
636636
- name: set verbose
637637
href: set-verbose.md
638638
- name: simulate restore
639-
href: simulate-restore.md
639+
href: simulate-restore.md
640640
- name: unexpose
641641
href: unexpose.md
642642
- name: writer
@@ -650,7 +650,7 @@
650650
- name: driverquery
651651
href: driverquery.md
652652
- name: dtrace
653-
href: dtrace.md
653+
href: dtrace.md
654654
- name: echo
655655
href: echo.md
656656
- name: edit
@@ -693,7 +693,7 @@
693693
- name: fsutil behavior
694694
href: fsutil-behavior.md
695695
- name: fsutil clfs
696-
href: fsutil-clfs.md
696+
href: fsutil-clfs.md
697697
- name: fsutil-devdrv
698698
href: fsutil-devdrv.md
699699
- name: fsutil dirty
@@ -1324,7 +1324,9 @@
13241324
- name: set environmental variables
13251325
href: set_1.md
13261326
- name: setlocal
1327-
href: setlocal.md
1327+
href: setlocal.md
1328+
- name: setspn
1329+
href: setspn.md
13281330
- name: setx
13291331
href: setx.md
13301332
- name: sfc
@@ -1567,7 +1569,7 @@
15671569
- name: wdsutil get driverpackage
15681570
href: wdsutil-get-driverpackage.md
15691571
- name: wdsutil get driverpackagefile
1570-
href: wdsutil-get-driverpackagefile.md
1572+
href: wdsutil-get-driverpackagefile.md
15711573
- name: wdsutil get image
15721574
href: wdsutil-get-image.md
15731575
- name: wdsutil get imagefile
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: Setspn
3+
description: The setspn command reads, modifies, and deletes the Service Principal Names (SPN) directory property for an Active Directory service account.
4+
ms.topic: reference
5+
ms.author: alalve
6+
author: xelu86
7+
ms.date: 03/24/2025
8+
ms:assetid: 9341c753-11ff-4acc-993c-b05d50f32330
9+
---
10+
11+
# setspn
12+
13+
The `setspn` command line utility reads, modifies, and deletes the Service Principal Names (SPN) directory property for an Active Directory (AD) service account. You use SPNs to locate a target principal name for running a service. You can use `setspn` to view the current SPNs, reset the account's default SPNs, and add or delete supplemental SPNs. `Setspn` is available if you have the Active Directory Domain Services (AD DS) server role installed. `Setspn` must be ran through an elevated command prompt.
14+
15+
## Syntax
16+
17+
```
18+
setspn <modifiers switch> <accountname> [-R] [-S] [-D] [-L] [-C] [-U] [-Q] [-X] [-P] [-F] [-T] [-?] [/?]
19+
```
20+
21+
> [!NOTE]
22+
> The \<accountname> can be the computer name or domain\\name of the target computer or a user account. You can run `setspn -A` to add SPNs, but you should use `setspn -S` instead because it verifies that there are no duplicate SPNs.
23+
24+
## Parameters
25+
26+
| Parameters | Description |
27+
|--|--|
28+
| `<accountname>` | Specifies the desired AD account object for which to configure the SPN. Normally, the SPN is the NetBIOS name of the computer and optionally the domain that contains the computer account. However, any desired AD object name can be used. |
29+
| `-R` | Resets the default SPN registrations for the host names for the computer. |
30+
| `-S` | Adds the specified SPN for the computer, after verifying that no duplicates exist. |
31+
| `-D` | Deletes the specified SPN for the computer. |
32+
| `-L` | Lists the currently registered SPN for the computer. |
33+
| `-C` | Specifies that `accountname` is a computer account. |
34+
| `-U` | Specifies that `accountname` is a user account. |
35+
| `-Q` | Queries for any existing SPNs. |
36+
| `-X` | Performs a search of duplicate SPNs. |
37+
| `-P` | Suppresses progress to the console and can be used when redirecting output to a file or when used in an unattended script. No output is displayed until the command is complete. |
38+
| `-F` | Performs queries at the forest, rather than domain level. |
39+
| `-T` | Performs a query on the specified domain (or forest when `-F` is used). |
40+
| `-?` or <br>`/?` | Displays the command-line help information. If you run `setspn` without this parameter, it also displays the command-line help information. |
41+
42+
> [!NOTE]
43+
> `-C` and `-U` are exclusive. If neither is specified, the tool interprets `accountname` as a computer name if such a computer exists, and a user name if it doesn't.
44+
45+
## Remarks
46+
47+
Query Mode modifiers can be used with the `-S` switch in order to specify where the check for duplicates should be performed before adding the SPN.
48+
49+
- `-T` can be specified multiple times. To indicate the current domain or a forest, use `""` or `*`.
50+
51+
- `-Q` executes on each target domain or forest.
52+
53+
- `-X` returns duplicates that exist across all targets. SPNs aren't required to be unique across forests, but duplicate SPNs can cause authentication issues during cross-forest authentication.
54+
55+
- SPNs must be constructed using the base name of the account specified as the _accountname_ parameter. If this condition isn't met, the directory service returns a constraint violation error.
56+
57+
You might not have the rights to access or modify this property on some account objects. You can determine what your access rights are by viewing the security attributes of the account object using the Microsoft Management Console (MMC) in Active Directory Users and Computers. You can also delegate the permission by assigning the Validated write to service principal name permission to the desired user or group.
58+
59+
The built-in SPNs that are recognized for computer accounts are:
60+
61+
```
62+
alerter eventlog netlogon rpc snmp
63+
appmgmt eventsystem netman rpclocator spooler
64+
browser fax nmagent rpcss tapisrv
65+
cifs http oakley rsvp time
66+
cisvc ias plugplay samss trksvr
67+
clipsrv iisadmin policyagent scardsvr trkwks
68+
dcom messenger protectedstorage scesrv ups
69+
dhcp msiserver rasman schedule w3svc
70+
dmserver mcsvc remoteaccess scm wins
71+
dns netdde replicator seclogon www
72+
dnscache netddedsm
73+
```
74+
75+
These SPNs are recognized for computer accounts if the computer has a host SPN. Unless they're explicitly placed on objects, a host SPN can substitute for any of the mentioned SPNs.
76+
77+
SPNs aren't case sensitive when used by Microsoft Windows-based computers. Any type of computer system can use an SPN. Many of these computer systems, especially UNIX-based systems, are case-sensitive, and require the proper case to function properly. Care should be taken to use the proper case particularly when an SPN is used by a non-Windows-based computer.
78+
79+
## Examples
80+
81+
To list all the registered SPNs for an account, type:
82+
83+
```cmd
84+
setspn -L <accountname>
85+
```
86+
87+
To reset the SPNs for a computer account, type:
88+
89+
```cmd
90+
setspn -R <accountname>
91+
```
92+
93+
To register the SPN _http/MyServer_ for user account _User01_, type:
94+
95+
```
96+
setspn -U -S http/MyServer User01
97+
```
98+
99+
To add a new SPN to a domain account that doesn't have one set, type:
100+
101+
```cmd
102+
setspn -S http/myserver.mydomain.com myDomain\myServer
103+
```
104+
105+
To remove an SPN from an account, type:
106+
107+
```cmd
108+
setspn -D http/myserver.mydomain.com myDomain\myServer
109+
```
110+
111+
To query all duplicate SPNs in your domain and the _contoso_ domain, type:
112+
113+
```
114+
setspn -T * -T contoso -X
115+
```
116+
117+
To find all the SPNs associated with _MyServer_ registered in the _contoso_ domain forest, type:
118+
119+
```
120+
setspn -T contoso -F -Q */MyServer
121+
```
122+
123+
## See also
124+
125+
[Command-Line Syntax Key](/windows-server/administration/windows-commands/command-line-syntax-key)

WindowsServerDocs/administration/windows-commands/windows-commands.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,8 @@ To find information about a specific command, in the following A-Z menu, select
713713
- [set metadata](set-metadata.md)
714714
- [set option](set-option.md)
715715
- [set verbose](set-verbose.md)
716+
- [setlocal](setlocal.md)
717+
- [setspn](setspn.md)
716718
- [setx](setx.md)
717719
- [sfc](sfc.md)
718720
- [shadow](shadow.md)

0 commit comments

Comments
 (0)