dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Get-DbaSpn

This function will take in a -ComputerName or -AccountName parameter and return an array of objects that list all currently set SPNs for a given remote computer.

If you’re expecting the output of setspn -l domain\username, you must run the following:

Get-DbaSpn -AccountName domain\sqlserver | Where-Object SPN -like CORPSQL1 | Select SPN

This is because the Get-DbaSpn is intended to run on a large number of machines, so it does not target only the computer it is currently running on. We are working on a new feature that will make getting this output more straightforward.

Screenshots

Examples

Return a list of SPNs that have been set for a remote computer and all discovered instances of SQL Server

Get-DbaSpn -ComputerName sqlserverc

Use alternate Windows credentials to gather a list of SPNs that have been set for a remote computer and all discovered instances of SQL Server.

Get-DbaSpn -ComputerName sqlservera -Credential (Get-Credential)

Author

This command was created by Drew Furgiuele. You can find Drew tweeting about SQL Server and PowerShell on Twitter and blogging at port1433.com.

Get-Help

From PowerShell, execute Get-Help Get-DbaSpn -Detailed for more information on this function.

Source Code

Want to see the source code? View Get-DbaSpn.ps1 on GitHub
 

Related commands