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

VB ScriptWindows Server 2003

Avatar of undefined
Last Comment
RobSampson

8/22/2022 - Mon
Jared Luker

Can we get the exact text of the error?
Jared Luker

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
RobSampson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
sunnyd24

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?
Your help has saved me hundreds of hours of internet surfing.
fblack61
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
RobSampson

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.
ASKER
sunnyd24

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.
RobSampson

No problem, thanks for the grade.

Regards,

Rob.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.