Remotely get WMI info from Security Center?

J

Jimmy B

Hi all, I have a sample script that gets this locally just fine, but when I
replace the "." with the "ComputerName", it gives me an error. ?


strComputer = "." 'Can set to remote machine.

On Error Resume Next
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\SecurityCenter")

Set colItems = oWMI.ExecQuery("Select * from AntiVirusProduct")

If Err = 0 Then
For Each objAntiVirusProduct In colItems
WScript.Echo "companyName: " & objAntiVirusProduct.companyName
WScript.Echo "displayName: " & objAntiVirusProduct.displayName
WScript.Echo "instanceGuid: " & objAntiVirusProduct.instanceGuid
WScript.Echo "onAccessScanningEnabled: " &
objAntiVirusProduct.onAccessScanningEnabled
WScript.Echo "productUptoDate: " & objAntiVirusProduct.productUptoDate
WScript.Echo "versionNumber: " & objAntiVirusProduct.versionNumber
Next
Else
Err.Clear
WScript.Echo "Unable to connect to SecurityCenter class on " & strComputer &
"."
WScript.Echo " Error Number:" & Err.Number
WScript.Echo " Source:" & Err.Source
WScript.Echo " Description:" & Err.Description
End If
 
M

Manbinder Pal Singh [MSFT]

Remove "On Error Resume Next"
and please see what error and what exactly fails?

My guess is that your remote computer which you are giving is not
configured. Please configure following the link
http://msdn2.microsoft.com/en-us/library/aa389290.aspx

Thanks,
Manbinder Pal Singh

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jimmy B

Thanks! That led me to look at things more closely. I had my DCOM turned
off (for diagnostic reasons) on my local computer, so WMI wasn't working on
any of my scripts. DUH!
 
M

Manbinder Pal Singh [MSFT]

Ok Great to know that :)

Thanks,
Manbinder Pal Singh

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top