GetObject error when connecting to remote computer....



I have a script that run locally. This script is used to stop and then
restart services
based on a wildcard match. We have services on multiple servers (all are
standalone) that begin with the same characters "TCWeb-". So the error I get
is Error: Permission denied: 'GetObject'

Here's the script:
Set objWMI =
GetObject("winmgmts:{impersonationLevel=impersonate}\\.\root\cimv2")
Set colServices = objWMI.ExecQuery ("Select * From Win32_Service Where Name
Like " & "'" & "TCWeb-%" & "'")

So when I change \\.\root\cimv2 to \\szComputer\root\cimv2 it fails with the
permission denied. Again since all these servers are standalone I need to
provide the username/password to connect with so that I can query and then
restart the services.

How do I do that? Can I supply the username/password in the connection
string?

Thanks.
.



Relevant Pages