2

I'm trying to run a simple Get-WmiObject call in PowerShell.

Get-WmiObject -computerName $srv -namespace root\Microsoft\SqlServer\ComputerManagement -class SqlService

When running under an account that has administrator rights to the remote server I get no response. The command does complete, but no data is shown. When running this command under an account that does not have rights to the server I get an "Access Denied" message.

When I run this on the remote server directly I get "Invalid namespace", but the server is definitely our SQL Server 2008.

Why doesn't this kind of script return the object as expected?

2 Answers 2

3

Try

Get-WmiObject -computerName $srv -namespace root\Microsoft\SqlServer\ComputerManagement10 -class SqlService

On several machines I have, the namespace is ComputerManagement10.

BTW, just in case, you need to find the namespace names:

Get-WmiObject -ComputerName $srv -NameSpace root\Microsoft\SQLServer -Class "__NAMESPACE" | Select Name

The above command will tell you the right namespace names.

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

1 Comment

Turned out all I needed to do was add "10" on to the end of ComputerManagement. Thanks.
0

Have you checked services with get-service -computername $srv -include “*sql*”?

I would also check whether the class is present in:

Get-WmiObject -Namespace root\Microsoft\SqlServer\ComputerManagement10 -List

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.