I have been using the MSDN article Enable or Disable a Server Network Protocol (SQL Server PowerShell) and am running into issues on the line:
$uri = "ManagedComputer[@Name='<computer_name>']/ ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Np']"
The error message I get is:
Exception calling "GetSmoObject" with "1" argument(s): "Attempt to retrieve data for object failed for ManagedComputer '<computer_name>'."
At line:1 char:24
+ $Np = $wmi.GetSmoObject <<<< ($uri)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
I am replacing <computer_name>
with the name of my computer. I have also tried omitting <computer_name>
from my command (I am trying to configure the machine from which I am running the script), and the I get the same error, including it showing the correct <computer_name>
in the error. I have also tried omitting everything from the first /
on, with no luck.
I have tried using cmd
, powershell
, and sqlps
. I am logged in as Administrator, and all of my windows say Administrator at the top, so I take that to mean that I am running the commands as administrator.
I am running on Windows Server 2012, with MS Sql Server 2012 installed.
My long term goal is to create a utility to setup SQL Server on a new machine without the need for user interaction.
How can I resolve my issue with the line of code from the MSDN article?
SELECT @@SERVICE
the result isMSSQLSERVER
.Import-Module "sqlps" -DisableNamechecking
and went back to explicitly putting in the<computer_name>
, and now it works. I think I was getting errors because of not doing the import module, but by the time I imported it, I started leaving the computer name blank, and started getting XPath errors.