Link to home
Start Free TrialLog in
Avatar of sunnyd24
sunnyd24

asked on

WMI Error on GetObject line, Error 70

If there was an impossible level I would definitely set this question to that difficulty.  

WMI isn't working correctly on all of my servers(about 200).  They are all returning an error 70 for the script:

I have ran the WMI diagnostics script from MS and it did not come back with any errors.  I can connect to \root\Wmi just fine.

We have been making mass GPO changes, but I have combed through and not seen anything that could remotely affect WMI, but I am at a loss to where to go now to continue troubleshooting.  I have checked the permissions on the box/files/namespaces/folders, etc...

Any clues on how to find what is causing this?
On Error Resume Next
OutputFile2="WMI_success.txt"
Set oFSO2 = CreateObject("Scripting.FileSystemObject")
Set oFile2 = oFSO2.CreateTextFile(OutputFile2, True)
OutputFile3="WMI_Failed.txt"
Set oFSO3 = CreateObject("Scripting.FileSystemObject")
Set oFile3 = oFSO3.CreateTextFile(OutputFile3, True)
 
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
 
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://ou=Blah,dc=Stuff,dc=Com' WHERE " & _
        "objectCategory='Computer'"  
 
Set objRecordSet = objCommand.Execute
 
objRecordSet.MoveFirst
 
Do Until objRecordSet.EOF
    Set objComputer = GetObject(objRecordSet.Fields("ADsPath").Value)
 
Set objWMIService = GetObject("winmgmts:\\" & objComputer.CN & "\root\cimv2")
If Err.Number <> 0 Then
oFile3.WriteLine(objComputer.CN)
Else
Set colFolders = objWMIService. _
    ExecQuery("Select * From Win32_Directory where Name = 'C:\\Windows'")
 
If colFolders.Count = 0 Then
			oFile3.WriteLine(objComputer.CN & " 0 folders Found")
'wscript.echo "Bullshit"
ElseIf colFolders.Count = 1 Then
			oFile2.WriteLine(objComputer.CN)
'wscript.echo "Found C:\Windows"
End If 
End If
    objRecordSet.MoveNext
    
Loop
 
msgbox "Done"

Open in new window

Avatar of Jared Luker
Jared Luker
Flag of United States of America image

Can we get the exact text of the error?
You have two backslashes on line 35... I'm not sure if that's related or not...

    ExecQuery("Select * From Win32_Directory where Name = 'C:\\Windows'")
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunnyd24
sunnyd24

ASKER

Rob,

Thanks for clearing that up.  There were some that were working properly.  The exact error message is below:

Line 31 (Getobject)
Char: 1
Error: Permission denied: 'GetObject'
Code: 800A0046
Source: Microsoft VBScript runtime error
and the WMI Error is a 70

My username is in the administrators group

Any ideas what to check?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, is the account that you're running the script from a member of that computer local Administrator's group (or the domain Admin group)?

Regards,

Rob.
Much appreciated Rob.  Clearing the errors helped filter out the false positives and it was indeed a GPO changing the DCOM that was the problem.
No problem, thanks for the grade.

Regards,

Rob.