Click here to Skip to main content
15,891,184 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
jackbrownii12-Aug-19 5:23
professionaljackbrownii12-Aug-19 5:23 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
dandy7212-Aug-19 7:45
dandy7212-Aug-19 7:45 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
DerekT-P12-Aug-19 8:57
professionalDerekT-P12-Aug-19 8:57 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
dandy7212-Aug-19 12:12
dandy7212-Aug-19 12:12 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
Mike Winiberg11-Aug-19 21:43
professionalMike Winiberg11-Aug-19 21:43 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
kalberts11-Aug-19 21:02
kalberts11-Aug-19 21:02 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
Sander Rossel11-Aug-19 21:42
professionalSander Rossel11-Aug-19 21:42 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
John Bevan11-Aug-19 21:57
John Bevan11-Aug-19 21:57 
If it helps, you can find this info on the `SqlStudio.bin` file (under `%AppData%`).

Here's some PowerShell to help make sense of the file's content: Get List of Servers from SSMS (i.e. historically used connections list from the New Connection dialogue) · GitHub[^]

PowerShell
Add-Type -Path (Get-Command 'Microsoft.SqlServer.Management.UserSettings.dll').Source
[bool]$loaded = $false
Get-Item -Path 'C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.ConnectionInfo\*\Microsoft.SqlServer.ConnectionInfo.dll' | Select-Object -ExpandProperty FullName | Sort-Object -Descending | ForEach-Object {if (!$loaded ){try {Add-Type -Path $_;Write-Verbose "Successfully loaded $_";$loaded=$true}catch{Write-Warning "Failed to load $_"}}}

[string]$settingsFilePath = (Resolve-Path (Join-Path -Path $env:APPDATA -ChildPath 'Microsoft/SQL Server Management Studio/*/SqlStudio.bin')).Path | Sort-Object -Descending | Select-Object -First 1
if ($settingsFilePath) {
    try {
        [System.IO.MemoryStream]$ms = [System.IO.File]::ReadAllBytes($settingsFilePath)
        [System.Runtime.Serialization.Formatters.Binary.BinaryFormatter]$formatter = New-Object -TypeName 'System.Runtime.Serialization.Formatters.Binary.BinaryFormatter'
        [Microsoft.SqlServer.Management.UserSettings.SqlStudio]$sqlStudio = $formatter.Deserialize($ms) #[Microsoft.SqlServer.Management.UserSettings.SettingsDictionary[[System.Guid],[Microsoft.SqlServer.Management.UserSettings.ServerTypeItem]]]
        foreach ($serverTypeItem in $sqlStudio.SSMS.ConnectionOptions.ServerTypes.Values) { #[Microsoft.SqlServer.Management.UserSettings.ServerTypeItem]
            foreach ($server in $serverTypeItem.Servers) { # [Microsoft.SqlServer.Management.UserSettings.ServerConnectionItem]
                ([PSCustomObject][Ordered]@{
                    Instance = $server.Instance
                    AuthMeth = ([Microsoft.SqlServer.Management.Common.SqlConnectionInfo+AuthenticationMethod]$server.AuthenticationMethod)
                    Connections = $server.Connections
                })
            
            }
        }
    } finally {
        $ms.Dispose()
    }
} else {
    throw 'Could not find SqlStudio.bin.  Older versions used MRU.dat... but I''ve not coded a solution for that, sorry!' 
}

The connection settings are held in a dictionary, so you can easily use the REMOVE method to pick things out of that list; then serialise to file to persist any changes.

Not quite as easy as deleting through the UI; but useful if you wanted to automate the management of this list in some way (e.g. have scripts preset to change the list according to which system/client you're working with).

modified 12-Aug-19 4:06am.

GeneralRe: Wow, it only took me way to many years to learn this... Pin
Nick Schwertfeger17-Aug-19 3:45
professionalNick Schwertfeger17-Aug-19 3:45 
GeneralRe: Wow, it only took me way to many years to learn this... Pin
Sander Rossel17-Aug-19 4:11
professionalSander Rossel17-Aug-19 4:11 
GeneralDoes Captain Hook... Pin
DRHuff10-Aug-19 3:46
DRHuff10-Aug-19 3:46 
GeneralRe: Does Captain Hook... Pin
Sander Rossel10-Aug-19 4:07
professionalSander Rossel10-Aug-19 4:07 
GeneralRe: Does Captain Hook... Pin
Michael Martin10-Aug-19 4:23
professionalMichael Martin10-Aug-19 4:23 
GeneralRe: Does Captain Hook... Pin
Gary R. Wheeler10-Aug-19 15:06
Gary R. Wheeler10-Aug-19 15:06 
GeneralRe: Does Captain Hook... Pin
RickZeeland10-Aug-19 4:49
mveRickZeeland10-Aug-19 4:49 
GeneralRe: Does Captain Hook... Pin
DRHuff10-Aug-19 5:38
DRHuff10-Aug-19 5:38 
GeneralRe: Does Captain Hook... Pin
Chris C-B10-Aug-19 5:50
Chris C-B10-Aug-19 5:50 
GeneralRe: Does Captain Hook... Pin
RickZeeland10-Aug-19 5:53
mveRickZeeland10-Aug-19 5:53 
GeneralStupid IoT device OTW Pin
OriginalGriff9-Aug-19 22:32
mveOriginalGriff9-Aug-19 22:32 
GeneralRe: Stupid IoT device OTW Pin
lopatir9-Aug-19 22:50
lopatir9-Aug-19 22:50 
GeneralRe: Stupid IoT device OTW Pin
Mark_Wallace10-Aug-19 0:57
Mark_Wallace10-Aug-19 0:57 
GeneralRe: Stupid IoT device OTW Pin
Mike Hankey10-Aug-19 1:49
mveMike Hankey10-Aug-19 1:49 
GeneralRe: Stupid IoT device OTW Pin
Sander Rossel10-Aug-19 1:50
professionalSander Rossel10-Aug-19 1:50 
GeneralRandom CCC Pin
Peter_in_27809-Aug-19 21:46
professionalPeter_in_27809-Aug-19 21:46 
GeneralRe: Random CCC Pin
OriginalGriff9-Aug-19 22:09
mveOriginalGriff9-Aug-19 22:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.