SOLVED

Registering SQLServers in SSMS v20 using Powershell

Copper Contributor

Hello
I have a new VM - Windows 11,

Installed SSMS V20.1 today
Installed SQLServer Powershell Module. SQLServer Module version is 22.2.0 . Only 1 version installed.

(Install-Module -Name SqlServer -Repository PSGallery -Force)

When I go into powershell and do the following
Set-Location "SQLSERVER:\SQLRegistration\database Engine Server Group"
new-item "TestFolder"

 

This TestFolder does not show up in SSM v20 (Registered Servers Group)

Similarly If i got into SSMS v20, and create a folder named "TestSSMS", 
This does not show up in the powershell sqlserver directory

I need to run a powershell command that populates the registered servers list. there are at least 30 servers that i need to register - hence powershell is a better option to do the registration. 


Any help would be grateful to fix this?

 

 

4 Replies

@UnknownSQLDBA It's easier to use "DbaTools" PowerShell CmdLet, see

dbatools docs | Add-DbaRegServer

I tried that as well.
Add-DbaRegServer -ServerName SQLName1
Get-DbaRegisteredServer -- shows me that it is added

But when i go into SSMS, its not in the registered list. (restarted and refreshed ssms as well)

best response confirmed by UnknownSQLDBA (Copper Contributor)
Solution
I have the same issue. The reason that this is happening is that SSMS v20 creates the file RegSrvr17.xml for storing the registered server groups and the cmdlet created the file RegSrvr16.xml. You can find these files at the path C:\Users\m.ntallaris(user name)\AppData\Roaming\Microsoft\SQL Server Management Studio. Unfortunately I have not find a solution to this, still searching though. An interesting fact if you install and use SSMS 19 will work perfectly, but if you install and use SSMS 18 no because this uses RegSrvr.xml. Another interesting fact is that if you search the release logs of SSMS 18 Microsoft point out that it has now this file in the AppData folder and not as a .bin (as the previous versions had) in order to all versions to have easy access to the registered servers, but in very next version Microsoft chose to rename the file...
Thanks for this 🙂
I renamed RegSrvr16.xml to RegSrvr17.xml and now my SSMS v20 is populated
A simple workaround - works for me.

1 best response

Accepted Solutions
best response confirmed by UnknownSQLDBA (Copper Contributor)
Solution
I have the same issue. The reason that this is happening is that SSMS v20 creates the file RegSrvr17.xml for storing the registered server groups and the cmdlet created the file RegSrvr16.xml. You can find these files at the path C:\Users\m.ntallaris(user name)\AppData\Roaming\Microsoft\SQL Server Management Studio. Unfortunately I have not find a solution to this, still searching though. An interesting fact if you install and use SSMS 19 will work perfectly, but if you install and use SSMS 18 no because this uses RegSrvr.xml. Another interesting fact is that if you search the release logs of SSMS 18 Microsoft point out that it has now this file in the AppData folder and not as a .bin (as the previous versions had) in order to all versions to have easy access to the registered servers, but in very next version Microsoft chose to rename the file...

View solution in original post