kerberos
$results = setspn -Q "MSSQLSvc/*" | Where-Object { $_ -match "^MSSQLSvc/" }
$parsed = $results | ForEach-Object {
if ($_ -match "^(MSSQLSvc/.*?):\s*(CN=.*)$") {
[PSCustomObject]@{
SPN = $matches[1]
Account = $matches[2]
}
} elseif ($_ -match "^(MSSQLSvc/.*)$") {
[PSCustomObject]@{
SPN = $matches[1]
Account = ""
}
}
}
$parsed | Export-Csv -Path MSSQL_SPNS.csv -NoTypeInformation
Comments
Post a Comment