3

I am attempting to use Powershell v2 to add registered servers in SQL Server Management Studio 2008.

So far I have the following outline

add-pssnapin SqlServerProviderSnapin100
add-pssnapin SqlServerCmdletSnapin100
##get-pssnapin

sl "SQLSERVER:\SQLRegistration\Database Engine Server Group"

new-item SERVERNAME\INSTANCENAME -itemtype registration -Value "server=SERVERNAME\INSTANCENAME;integrated security=false;User Id=SA;Password=foofoo"

The problem I have is with the registered server friendly name. We require slashes in it as we have named instances with the same names on different servers.

Regardless of what I try I get the following error message.

The type is not a known type for the file system. Only "file" and "directory" can be specified

I have tried enclosing in quotes, using grave as an escape character. None of which works for me.

Cheers
David

1 Answer 1

2

You need to use the encode-sqlname cmdlet which is part of the SqlServerCmdletSnapin100. Here's an example:

New-Item $(Encode-Sqlname "SERVERNAME\INSTANCENAME") -itemtype registration -Value “server=MyServer;integrated security=true” 

I have a couple of blog posts about registering servers here also: http://sev17.com/2008/12/registering-sql-servers-in-2000-em-2005-ssms-and-2008-ssms/ and here http://sev17.com/2009/01/dynamically-register-sql-instances-in-sql-server-management-studio-2008/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.