I would like to add a bunch of SQL (mixture of 2000-2005) server instances on different servers to my SSMS (SQL Managment Studio) Registered servers, I was following this tutorial here but this only adds one server at a time not all at the same time.
The list is currently in Excel but can be imported to notepad or any other document format as long as it can be recognized by the PowerShell command. Also, another thing to note is where can i change the login to use sql authentication? and specify username and password?
New-Item $(Encode-Sqlname "SERVERNAME\INSTANCENAME") -itemtype registration -Value “server=MyServer;integrated security=true”
tks
ERROR
New-Object : Cannot convert argument "1", with value: "", for "PSCredential" to
type "System.Security.SecureString": "Cannot convert the "" value of type "Sys
tem.String" to type "System.Security.SecureString"."
At line:4 char:32
+ -Credential (New-Object <<<< System.Management.Automation.PSCredenti
al("sa", "")) }
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodExcept
ion
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Shell.Commands.NewObjectCommand
If you save the Excel spreadsheet as a CSV file, you can easily import it in PowerShell using the Import-Csv cmdlet and automatically register the servers in the list by their names.
Assuming your CSV file looks like this:
The following command will import its content as a list of objects, one for each row in the CSV file, all having a
Nameproperty, which contains the actual value. Those names are then used within the string passed to the New-Item cmdlet to actually do the registration:You can specify the username and password to use to connect to the SQL Server instance by passing a PSCredential object to the New-Item cmdlet. So the complete command would be: