Checks expected MSSQLSvc SPNs for all SQL Server instances on one or more computers. Detects missing and unexpected SPNs, resolves the service account type (Domain / Computer / NoNetwork), reads the SQL port from the registry, and optionally checks AlwaysOn listener SPNs. Produces ready-to-use setspn.exe commands for missing entries.
Execution Flow
Synopsis
Determines all SQL Server services on each target computer via Win32_Service (CIM), resolves the service account type, reads the SQL TCP port from the registry, and derives the four expected MSSQLSvc SPNs per instance. Existing SPNs are read via setspn.exe -L. Missing SPNs include a ready-to-use setspn -S command. Unexpected SPNs (stale after port changes) include a setspn -D command. The AD module is not required.
Requires setspn.exe in the system path (standard on domain-joined Windows). No dbatools required for the main SPN check; dbatools is used optionally for AlwaysOn listener SPN detection. Local admin rights on the target computer required for WMI/CIM queries.
Wildcard filter on instance name (e.g. 'MSSQLSERVER' for default only).
-OutputPath
String
Get-sqmConfig 'OutputPath'
Directory for TXT and CSV report files.
-ContinueOnError
Switch
false
Continue with the next instance on error.
-EnableException
Switch
false
Throw terminating exceptions.
-NoOpen
switch
$false
Do not automatically open the generated report after creation.
-SqlCredential
PSCredential
,
Optional SQL credential used ONLY for the AlwaysOn-listener SPN check, which queries the instance (sys.availability_group_listeners) via dbatools' Invoke-DbaQuery. The core SPN report (service accounts, expected/existing MSSQLSvc SPNs) is WMI/CIM/registry- and setspn-based and needs no SQL connection. If omitted, the listener query connects with the current Windows identity; if dbatools is not available, the listener check is skipped and the rest of the report is produced normally.
SPN Status Values
Status
Meaning
OK
SPN exists and matches expected value.
Missing
Expected SPN not found. SetSpnCommand contains the fix.
Unexpected
SPN exists but is not in the expected list (stale after port change).
NoNetwork
LOCAL SERVICE account, no network identity, Kerberos not possible.
Examples
Example 1, Check all SQL instances on local computer