Setspn.exe corresponding PowerShell command

Source: Internet
Author: User
Tags setspn

Since the company's domain control upgrade to the R2, usually ad's work is basically PowerShell-based. This can force yourself to master the relevant cmdlets as early as possible, and self-feeling common work can be done by PowerShell.


The SETSPN command has been useless for years, and has not considered the PowerShell command. A client installed an SAP application, and needed to set up an SPN for a machine account, and then finished it with Setspn-a. I have been thinking, PowerShell should have a corresponding command, a simple search: Get-command *-ad*spn* also have no results.


Later on, the SPN is the attribute of the (computer and user) account, which should be set by Set-aduser after set-adcomputer to view help, without parameters to set the SPN directly. Compared to the traditional dsmod, these two set-ad* commands can also set the properties of the non-parametric control, the corresponding help is as follows:
The Set-adcomputer cmdlet modifies the properties of an Active Directory computer object. You can modify commonly used property values by using the cmdlet parameters. Property values is not a associated with cmdlet parameters can is modified by using the ADD, Replace, Clear and Remove Parameters.


So, setspn-a can be set-adcomputer <ADcomputer>-add @{serviceprincipalname= "XXX"} or Set-aduser <ADuser>-add @ {serviceprincipalname= "XXX"} to replace;
Setspn-d can be set-adcomputer <ADcomputer>-remove @{serviceprincipalname= "XXX"} or Set-aduser <ADuser>- Remove @{serviceprincipalname= "XXX"} to replace;


To put it simply, PowerShell's-add replaced the-a,-reomve instead of-D. At the same time, PowerShell is not simply a replacement, there are two more powerful parameters setspn did not:
-clear servicePrincipalName will clear all the SPNs;
-replace @{serviceprincipalname= "SPN1", "SPN2"} to implement the replacement of the SPN.


This blog is written here to stop the pen, and finally remind the Ad Module PowerShell user, Ad object Common properties can be modified by parameters, unusual parameters Add, replace or remove+ hash table, and clear+ property name for editing.

This article is from the "Powersheller Shell" blog, please be sure to keep this source http://powersheller.blog.51cto.com/4428055/1634549

Setspn.exe corresponding PowerShell command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.