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?
3条答案
按热度按时间qnakjoqk1#
If you failed like me for SQLExpress (version 12 = 2014):
look at this registry location:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQLServer\SuperSocketNetLib\Tcp
the manager shows the value, but I cannot change the values in Win10 - UI issue. C:\Windows\System32\SQLServerManager12.msc
8tntrjer2#
I included this line at the beginning of the powershell script:
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.
lmvvr0a83#
Enable TCP and Named Pipes on a Named SQL Server instance Tested against Server 2022 Express