Skip to content

Instantly share code, notes, and snippets.

@AScriver
Created October 7, 2022 18:28
Show Gist options
  • Save AScriver/745d3f47b2f5e7c26e0d6cdbcead7c5d to your computer and use it in GitHub Desktop.
Save AScriver/745d3f47b2f5e7c26e0d6cdbcead7c5d to your computer and use it in GitHub Desktop.
Dumps connection strings saved in SSMS
Invoke-Sqlcmd | Out-Null
Get-ChildItem 'SQLSERVER:\sqlregistration\Database Engine Server Group' -Recurse `
| Where-Object {$_ -is [Microsoft.SqlServer.Management.RegisteredServers.RegisteredServer]} `
| Select-Object DisplayName, ConnectionString `
| ConvertTo-Json -Depth 3 -Compress `
| Out-File -FilePath .\output.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment