changing SSMS settings via Powershell

All we need is an easy explanation of the problem, so here it is.

in order to enable the dark theme to SSMS (not available on the picture below as you see):

changing SSMS settings via Powershell

following this webpage:

SQL SERVER Management Studio 18 – Enable Dark Theme – SQL Authority with Pinal Dave

there are clear instructions as how to add the darktheme to SSMS. It works, but needs to be done manually.

changing SSMS settings via Powershell

now on this site below, there is the same set of instructions plus a way to get it done via powershell, as I have added here below, and it works, but powershell needs to be run as administrator.

Setting up the dark theme in SQL Server management studio (sqlshack.com)

Depending on the version of SSMS, copy the appropriate script into the clipboard, paste it in PowerShell and hit Enter to execute it:

SSMS 2016

powershell -Command "(gc 'C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\ssms.pkgundef') -replace '\[\`$RootKey\`$\\Themes\\{1ded0138-47ce-435e-84ef-9ec1f439b749}\]', '//[`$RootKey`$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}]' | Out-File 'C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\ssms.pkgundef'"

SSMS 17

powershell -Command "(gc 'C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\ssms.pkgundef') -replace '\[\`$RootKey\`$\\Themes\\{1ded0138-47ce-435e-84ef-9ec1f439b749}\]', '//[`$RootKey`$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}]' | Out-File 'C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\ssms.pkgundef'"

SSMS 18

powershell -Command "(gc 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.pkgundef') -replace '\[\`$RootKey\`$\\Themes\\{1ded0138-47ce-435e-84ef-9ec1f439b749}\]', '//[`$RootKey`$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}]' | Out-File 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.pkgundef'"

Powershell as administrator running the command above:

changing SSMS settings via Powershell

Now my question, I am not sure whether it is possible or not.
Basically I would like to find out where these SSMS settings are saved, and change them preferably via powershell:

  1. set the colour Theme as Dark
  2. Items shown on the windows menu – currently 10, I would like to change that to 24

is it at all possible?

I have many servers where SSMS lives, and I would like to set them all to the same settings.

I am wondering if I could get this done using SendKeys.

that added the dark theme – made it available for me to choose it as you can see on the picture below.

changing SSMS settings via Powershell

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Thanks to David Browne,

I used procmon and could find the settings are stored in the below regedit section,

Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\SQL Server Management Studio\18.0_IsoShell\General

MRUListItemCount

WindowMenuItemCount

Change these values to 1-24

Method 2

You could use Process Monitor https://docs.microsoft.com/en-us/sysinternals/downloads/procmon to discover where SSMS stores these settings.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply