Author | Drew Furgiuele (@pittfurg), port1433.com , niphlod |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Test-DbaSpn on GitHub.
Want to see the Bill Of Health for this command? Check out Test-DbaSpn.
Test-DbaSpn will determine what SPNs should be set for a given server (and any instances of SQL running on it) and return
whether the SPNs are set or not.
This function is designed to take in a server name(s) and attempt to determine required SPNs. It was initially written to mimic the (previously) broken functionality of the Microsoft Kerberos Configuration manager and SQL Server 2016.
Once the required SPNs are generated, the script will connect to Active Directory and search for any of the SPNs (if any) that are already set. The function will return a custom object(s) that contains the server name checked, the instance name discovered, the account the service is running under, and what the "required" SPN should be. It will also return a boolean property indicating if the SPN is set in Active Directory or not.
Test-DbaSpn
[-ComputerName] <DbaInstanceParameter[]>
[[-Credential] <PSCredential>]
[-EnableException]
[<CommonParameters>]
PS C:\> Test-DbaSpn -ComputerName SQLSERVERA -Credential ad\sqldba
Connects to a computer (SQLSERVERA) and queries WMI for all SQL instances and return "required" SPNs. It will then take each SPN it generates
and query Active Directory to make sure the SPNs are set.
PS C:\> Test-DbaSpn -ComputerName SQLSERVERA,SQLSERVERB -Credential ad\sqldba
Connects to multiple computers (SQLSERVERA, SQLSERVERB) and queries WMI for all SQL instances and return "required" SPNs.
It will then take each SPN it generates and query Active Directory to make sure the SPNs are set.
PS C:\> Test-DbaSpn -ComputerName SQLSERVERC -Credential ad\sqldba
Connects to a computer (SQLSERVERC) on a specified and queries WMI for all SQL instances and return "required" SPNs.
It will then take each SPN it generates and query Active Directory to make sure the SPNs are set. Note that the credential you pass must have be a valid login with appropriate rights on the domain
The computer you want to discover any SQL Server instances on. This parameter is required.
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
The credential you want to use to connect to the remote server and active directory.
Alias | |
Required | False |
Pipeline | false |
Default Value |
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |