setspn
The setspn command line utility reads, modifies, and deletes the Service Principal Names (SPN) directory property for an Active Directory (AD) service account. Windows commands reference
On Windows 1 Sigma rule name it File setspn.exe
Windows
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. 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. - -T can be specified multiple times. To indicate the current domain or a forest, use "" or *. - -Q executes on each target domain or forest. - -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. - 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. 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. The built-in SPNs that are recognized for computer accounts are: 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. 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.
setspn <modifiers switch> <accountname> [-R] [-S] [-D] [-L] [-C] [-U] [-Q] [-X] [-P] [-F] [-T] [-?] [/?]
To list all the registered SPNs for an account, type
setspn -L <accountname>Identify-LLists the currently registered SPN for the computer. Windows commands referenceTo reset the SPNs for a computer account, type
setspn -R <accountname>Identify-RResets the default SPN registrations for the host names for the computer. Windows commands referenceTo register the SPN _http/MyServer_ for user account _User01_, type
setspn -U -S http/MyServer User01Identify-USpecifies that accountname is a user account. Windows commands reference-SAdds the specified SPN for the computer, after verifying that no duplicates exist. Windows commands referenceTo add a new SPN to a domain account that doesn't have one set, type
setspn -S http/myserver.mydomain.com myDomain\myServerIdentify-SAdds the specified SPN for the computer, after verifying that no duplicates exist. Windows commands referenceTo remove an SPN from an account, type
setspn -D http/myserver.mydomain.com myDomain\myServerIdentify-DDeletes the specified SPN for the computer. Windows commands referenceTo query all duplicate SPNs in your domain and the _contoso_ domain, type
setspn -T * -T contoso -XIdentify-TPerforms a query on the specified domain (or forest when -F is used). Windows commands reference-XPerforms a search of duplicate SPNs. Windows commands referenceTo find all the SPNs associated with _MyServer_ registered in the _contoso_ domain forest, type
setspn -T contoso -F -Q */MyServerIdentify-TPerforms a query on the specified domain (or forest when -F is used). Windows commands reference-FPerforms queries at the forest, rather than domain level. Windows commands reference-QQueries for any existing SPNs. Windows commands referenceTrips 1 Sigma rule: mediumPotential SPN Enumeration Via Setspn.EXE by Markus Neis, keepwatch
Show 13 options
<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.-RResets the default SPN registrations for the host names for the computer.-SAdds the specified SPN for the computer, after verifying that no duplicates exist.-DDeletes the specified SPN for the computer.-LLists the currently registered SPN for the computer.-CSpecifies that accountname is a computer account.-USpecifies that accountname is a user account.-QQueries for any existing SPNs.-XPerforms a search of duplicate SPNs.-PSuppresses 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.-FPerforms queries at the forest, rather than domain level.-TPerforms a query on the specified domain (or forest when -F is used).-? or /?Displays the command-line help information. If you run setspn without this parameter, it also displays the command-line help information.