Jump to content

Remote WMI to workgroup systems


mattw112
 Share

Recommended Posts

My environment consists of many machines running Vista which are members of a workgroup (not domain).

I want to run a simple inventory of those systems for things such as Make, model, etc...

I have the script below but it does not work. Probably because I'm running from an account and machine which are part of the Domain.

The systems do all have a local admin account, let's call it "testuser" with a blank password. I need to know how to rewrite this a bit so that I can specify the credentials I have.

Thanks,

Terry

#Include <date.au3>
#include <file.au3>

Dim $ip, $manu, $model, $Serialnum, $Domain

$log = FileOpen("C:\INFO\list2.txt", 9)


For $x = 1 to 254
    $ip = "192.168.1." & $x

    _GetInfo($IP)

    FileWrite($log, "================================================" & @CRLF)
    FileWrite($log, "IP: " & $ip & @CRLF)
    FileWrite($log, "Manufacturer: " & $Manu & @CRLF)
    FileWrite($log, "Model: " & $Model & @CRLF)
    FileWrite($log, "Domain: " & $Domain & @CRLF)
    FileWrite($log, "SerialNum: " & $SerialNum & @CRLF)
    FileWrite($log, " " & @CRLF)
    FileWrite($log, "================================================" & @CRLF & @CRLF)

Next

FileClose($log)

Exit(0)

Func _GetInfo($ip)
    
    $objWMIService = ObjGet("winmgmts:\\" & $ip & "\root\CIMV2")

    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystem")

        For $objItem In $colItems
            $Model &= $objItem.Model
        Next

    $objWMIService = ObjGet("winmgmts:\\" & $ip & "\root\CIMV2")

    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystem")

        For $objItem In $colItems
            $Domain &= $objItem.Domain
        Next
        
    $objWMIService = ObjGet("winmgmts:\\" & $ip & "\root\CIMV2")

    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystem")

        For $objItem In $colItems
            $Manu &= $objItem.Manufacturer
        Next

    $objWMIService = ObjGet("winmgmts:\\" & $ip & "\root\CIMV2")

    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Bios")

        For $objItem In $colItems
            $SerialNum &= $objItem.SerialNumber 
        Next
    
EndFunc
Link to comment
Share on other sites

Hi there m8,

compile your script (yourscript.exe) and create a new one.

In that new one use RunAs ($user, "$IP", $password, 2, "location\yourscript.exe") to call your previous script.

I tested and the WMI runned smooth.

Give it a shoot! :mellow:

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

That isn't working.

When you tried this did you run it against machines in a workgroup? Not Domain members?

From reading here on the forums I think I need to rewrite the WMI statements to include some sort of impersonation? I'm just really not sure exactly how.

Also the other issue is when doing the IP scan what about non domain/workgroup members? Like Routers, or other equipment? Will it just fail or will it error out? Anythign I can add to this script to deal with that?

Oh and that reminds me, on that IP range even though most are workgroup machines there are several which are domain members. For those guys it would be a different username/password then on the workgroup machines... anyway to detect which one I got then use the right credentials?

Thanks,

Terry

Link to comment
Share on other sites

That isn't working.

When you tried this did you run it against machines in a workgroup? Not Domain members?

From reading here on the forums I think I need to rewrite the WMI statements to include some sort of impersonation? I'm just really not sure exactly how.

Also the other issue is when doing the IP scan what about non domain/workgroup members? Like Routers, or other equipment? Will it just fail or will it error out? Anythign I can add to this script to deal with that?

Oh and that reminds me, on that IP range even though most are workgroup machines there are several which are domain members. For those guys it would be a different username/password then on the workgroup machines... anyway to detect which one I got then use the right credentials?

Thanks,

Terry

Terry,

When you are using WMI, AutoIT don't know how to deal with WMI errors.

I tried to user a mass WMI connection before and i got some success by pinging the host first and ignoring hosts that returned time out.

I tried the script with a workgroup computer and it was sucessefull, i just scan one host, a valid one.

It's tricky to use WMI when you have no access to WMI, because it will end your script.

Cheers.

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...