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