Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SWbemLocator: Access is denied.

Status
Not open for further replies.

cluM09

Technical User
May 15, 2004
127
US
Hello,

I got the WMI code to run the script using an alternate credential, and it used to work. After Windows Server 2003 SP2 has been applied to my environment, the script generates the access denied error.

The code is listed below:

Const WbemAuthenticationLevelPktPrivacy = 6

strComputer = "server1"
strNamespace = "root\cimv2"
strUser = "administrator"
strPassword = "password"

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objwbemLocator.ConnectServer _
(strComputer, strNamespace, strUser, strPassword)
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy

Set colItems = objWMIService.ExecQuery _
("Select * From Win32_OperatingSystem")
For Each objItem in ColItems
Wscript.Echo strComputer & ": " & objItem.Caption
Next

I got the access error at the line:

Set objWMIService = objwbemLocator.ConnectServer _
(strComputer, strNamespace, strUser, strPassword)

I tested all my domain credential, and it worked fine including logging onto the server with the same credential.

What could be done to resolve this issue? Any help will be greatly appreciated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top