Jump to content

Inventory Gathering


RichE
 Share

Recommended Posts

Hi All,

I've wrote a script/util to get remote registry info from workstations (which works fine), but it's missing to key items (serial number, and Total Physical memory), which I can get from WMI in the BIOS.

I've also modded an existing Powershell Script from powershell.com to grab the same info, but get this... autoit script takes 10-15mins to process 1800 workstations, PS took over 10 hrs to do the same amount !?!

what I'd like to do is incorporate the two WMI bits into the autoit script, but don't know where to start, counld anyone help or point me in the right direction.

here's the autoit script:

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.3.5.6 (beta)
    Author:         Richard Easton
    
    Script Function:
    Remote Workstation Auditor.
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <string.au3>

$errors = 0



$audit_book = @ScriptDir & "\Auditbook_" & @MDAY & "_" & @MON & ".csv"
$error_log = @ScriptDir & "\Errorlogs\" & @MDAY & @MON & "_audit_errors.log"
If Not FileExists($audit_book) Then
    FileWriteLine($audit_book, "Computer Name, Location, Serial Number, CPU Type, CPU Speed, Motherboard Vendor, Motherboard Type, Motherboard Version, Operating System, Service Pack")
EndIf

If Not FileExists($error_log) Then
    DirCreate(@ScriptDir & "\Errorlogs")
    _FileWriteLog($error_log, "Error log created")
EndIf

GUICreate("Remote Workstation Auditor", 433, 289, -1, -1)
GUICtrlCreateGroup("Target Details", 8, 8, 417, 45)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;individual workstation
;multiple workstations
GUICtrlCreateLabel("Workstation List", 16, 28, 96, 17)
$Workstation_List = GUICtrlCreateInput("Workstation_List", 112, 24, 273, 21)
$wlist = GUICtrlCreateButton("...", 392, 22, 25, 23, $WS_GROUP)

;progress stuff
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Progress", 8, 61, 417, 65)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
;infor labels
GUICtrlCreateLabel("Current Location:", 19, 81, 121, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$lblCL = GUICtrlCreateLabel("None Selected", 122, 81, 74, 17)

GUICtrlCreateLabel("Workstation:", 220, 81, 121, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$lblCW = GUICtrlCreateLabel("None Selected", 295, 81, 74, 17)

GUICtrlCreateLabel("Workstation: ", 19, 100, 72, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$currentnumber = GUICtrlCreateLabel("0", 94, 100, 30, 17)
GUICtrlCreateLabel("of", 129, 100, 15, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$oftotal = GUICtrlCreateLabel("0", 152, 100, 30, 17)

;admin credentials
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Credential", 8, 130, 417, 95)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlCreateLabel("Username:", 19, 150, 121, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$admin = GUICtrlCreateInput(@UserName, 112, 146, 273, 21)

GUICtrlCreateLabel("Password:", 19, 172, 121, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$pass = GUICtrlCreateInput("", 112, 168, 273, 21, $ES_PASSWORD)

GUICtrlCreateLabel("Domain:", 19, 195, 121, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Domain = GUICtrlCreateInput("", 112, 191, 273, 21)


GUICtrlCreateGroup("", -99, -99, 1, 1)
$go = GUICtrlCreateButton("Process", 8, 255, 153, 25, $WS_GROUP)
$exit = GUICtrlCreateButton("Exit", 264, 256, 161, 25, $WS_GROUP)
GUICtrlCreateLabel("Removal Errors: ", 19, 232, 98, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$error_count = GUICtrlCreateLabel($errors, 119, 233, 50, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            MsgBox(64, "Thank you", "Thanks for using Remote Spec Audit, written by Richard Easton 2011.", 5)
            Exit
        Case $exit
            MsgBox(64, "Thank you", "Thanks for using Remote Spec Audit, written by Richard Easton 2011.", 5)
            Exit
        Case $go
            If GUICtrlRead($Workstation_List) = "" Or GUICtrlRead($Workstation_List) = "Workstation_List" Or GUICtrlRead($admin) = "" Or GUICtrlRead($pass) = "" Or GUICtrlRead($Domain) = "" Then
                MsgBox(48, "Warning!", "No .CSV file selected or one of the credentials are missing!", 10)
            Else
                ;runas(guictrlread($admin), guictrlread($Domain), guictrlread($pass), 2 , @comspec, @ScriptDir)
                $p = 0
                $target = GUICtrlRead($Workstation_List)
                $line_count = _FileCountLines($target)

                For $l = 2 To $line_count - 1
                    $input = FileReadLine($target, $l)
                    $data = StringSplit($input, ",")
                    $var = Ping($data[1], 250)
                    If $var Then
                        GUICtrlSetData($lblCL, $data[2], "")
                        GUICtrlSetData($lblCW, $data[1], "")
                        GUICtrlSetData($currentnumber, $l, "")
                        If @error Then ExitLoop

                        $vidloc = RegRead("HKLM\HARDWARE\DEVICEMAP\VIDEO", "\Device\Video4")
                        $v_str_len = StringLen($vidloc)
                        $true_vid_loc = "HKLM" & StringMid($vidloc, 18, $v_str_len)
                        $workstation_name = RegRead("\\" & $data[1] & "\HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName", "ComputerName")

                        ;cpu
                        $cpustr = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString")
                        $cpuid = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "Identifier")
                        $cpuspd = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz") & "~MHz"

                        ;mobo
                        $mobovendor = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardManufacturer")
                        $moboproduct = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardProduct")
                        $moboversion = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardVersion")

                        #cs
                            ;bios
                            $commacheck = StringInStr(RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\BIOS", "BIOSVendor"), 0, ",")
                            If $commacheck = 0 Then
                            $vendorcheck = StringSplit(RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\BIOS", "BIOSVendor"), ",")
                            $biosvendor = $vendorcheck[1]
                            Else
                            $biosvendor = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System\BIOS", "BIOSVendor")
                            EndIf
                            $biosversion = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System", "SystemBiosVersion")
                            ;$biosdate = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System", "SystemBiosDate")
                            
                            ;mem
                            $phmem = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\RESOURCEMAP\System Resources\Physical Memory", ".Translated")
                        #ce
                        ;OS
                        $osprod = RegRead("\\" & $data[1] & "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName")
                        If $osprod = "Windows 7 Professional" Then
                            $osSP = RegRead("\\" & $data[1] & "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CSDBuildNumber")
                        Else
                            $osSP = RegRead("\\" & $data[1] & "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CSDVersion")
                        EndIf
                        $osbuild = RegRead("\\" & $data[1] & "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuildNumber")
                        #cs
                            ;vid
                            $vidvendor = RegRead($true_vid_loc, "ProviderName")
                            $viddesc = RegRead($true_vid_loc, "Device Description")
                            If $data[6] = "Microsoft Windows XP" Then
                            $vidbios = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System", "VideoBiosVersion")
                            Else
                            $vidbios = RegRead($true_vid_loc, "HardwareInformation.BiosString")
                            EndIf
                            If $data[6] = "Microsoft Windows XP" Then
                            $vidbios = RegRead("\\" & $data[1] & "\HKLM\HARDWARE\DESCRIPTION\System", "VideoBiosVersion")
                            Else
                            $viddvrdate = RegRead($true_vid_loc, "DriverDate")
                            $viddrvver = RegRead($true_vid_loc, "DriverVersion")
                            EndIf
                        #ce
                        ;output.
                        ;FileWriteLine($audit_book, "Computer Name, Location, CPU Type, CPU Speed, Motherboard Vendor, Motherboard Type, Motherboard Version, Operating System, Service Pack")

                        FileWriteLine($audit_book, $data[1] & "," & $data[2] & ", ," & $cpustr & "," & $cpuspd & "," & $mobovendor & "," & $moboproduct & "," & $moboversion & "," & $data[6] & "," & $osSP)
                        ;Sleep(300)

                    Else
                        _FileWriteLog($error_log, $data[1] & " is not responding to a ping request")
                    EndIf
                Next
                If $error_count = 0 Then
                    _FileWriteLog($error_log, $data[2] & " Audited Successfully")
                    MsgBox(48, "Remote Spec Audit", "Audit completed successfully")
                Else
                    _FileWriteLog($error_log, $data[2] & " Audit completed with errors, error logs are located in your My Documents directory")
                    MsgBox(48, "Remote Spec Audit", "Audit completed with errors, error logs are located in your My Documents directory")

                EndIf

            EndIf


        Case $wlist
            $list = FileOpenDialog("Select CSV list of workstations", @MyDocumentsDir, "CSV (*.csv)", 1 + 2)
            GUICtrlSetData($Workstation_List, $list, "")
            $line_count = _FileCountLines($list)
            GUICtrlSetData($oftotal, $line_count - 1, "")
    EndSwitch
WEnd

the Serial Number WMI info is located in :

$SysItems1 = gwmi Win32_BIOS -Comp $StrComputer -Credential $cred

Subitem

$objItem.SerialNumber

and the memory is in :

$GenItems1 = gwmi Win32_ComputerSystem -Comp $StrComputer -Credential $cred

in subitem

$objItem.TotalPhysicalMemory

Thanks in advance

RichE

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Link to comment
Share on other sites

Can you test SIC2 for me please?

It collects some information about systems and can be started in parallel.

Thanks,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thank for such a quick reply.

Your SIC2, looks like a very powerful, I'll feedback to you once I've tried it.

on a side note, the script I've posted will not work correctly without a .csv output from Research Machines CC4 RMMC (Management Console), I've posted one up just so you can see what it contains

output.rar

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Link to comment
Share on other sites

After trawling the forums for enlightenment I found this http://www.autoitscript.com/forum/index.php?app=forums&module=forums&section=findpost&pid=884694

which contained the information that I required, after abit of tiggerey pokerey I shoe horned my new knowledge into my existing script, and went as far as to ditch ALL regread statements, I've now got all the information I required from ALL 1892 workstations in under 30mins, this will save me SOOOoooooo many man hours in looking for serial numbers :huh2:

the only drawback at the mo is that it reads output .csv from our RM console, but I'll tweak it to read a .txt file as well, and maybe post the tweaked code up if anyones interest in saving time auditing their hugh networks

Regard

RichE

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 2 months later...

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

GUICtrlSetData($lblCL, $data[2], "")

GUICtrlSetData($lblCL, ^ ERROR

I am facing this error again and again can anyone help me to solve this issue.

Do i need to deploy on any server addition and run after that i running this script on winxp .

Pls help me

Thanks in Advance

Link to comment
Share on other sites

yes I believe that it is referring to a location, which if the list does not have it, it will throw out this error.

try this one, it uses IP ranges instead of the exported csv list, and it will allow export after the audit has completed (it's still in the test phase atm)

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=E:\Downloads\Icons\junior-by-treetog-d3254md\Junior\Junior Icon 59.ico
#AutoIt3Wrapper_Outfile=RW Auditor IPV3.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=Audit remote workstation on your network
#AutoIt3Wrapper_Res_Description=RW Auditor Version3
#AutoIt3Wrapper_Res_Fileversion=3.0.1.5
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=Richard Easton 2011 @ Sellostring.co.uk & .com
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Run_Tidy=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.3.5.6 (beta)
    Author:         Richard Easton
    intergating WMI into an autoit script.
    
    Script Function:
    Remote Workstation Auditor.
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <File.au3>
#include <string.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <_GUICtrlListView_CreateArray.au3>
#include <_GUICtrlListView_SaveCSV.au3>
#include <GuiTab.au3>
#include <Date.au3>
#include <ie.au3>

Opt("TrayIconHide", 1)

Global $objSWbemLocator, $objSWbemServices


$errors = 0
$error_log = @ScriptDir & "\Errorlogs\" & @MDAY & @MON & "_audit_errors.log"
GUICreate("Remote Workstation Auditor", 1024, 768, -1, -1)
$tabz = GUICtrlCreateTab(5, 5, 1008, 752)
$audittab = GUICtrlCreateTabItem("Audit")


;progress stuff
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Progress", 10, 30, 996, 40)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
;infor labels
GUICtrlCreateLabel("Current Workstation:", 19, 45, 150, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$lblCW = GUICtrlCreateLabel("None Selected", 160, 45, 200, 17)


GUICtrlCreateLabel("Workstation: ", 350, 45, 72, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$currentnumber = GUICtrlCreateLabel("0", 440, 45, 30, 17)
GUICtrlCreateLabel("of", 470, 45, 15, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$oftotal = GUICtrlCreateLabel("0", 490, 45, 30, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)

;admin credentials

$table = GUICtrlCreateListView("Computer Name|IP Address|MAC Address|Serial Number|Type|Make|Model|CPU Type & Speed|CPU Cores|Memory (MB)|HDD size|Operating System|ServicePack", 10, 70, 995, 655, -1, $LVS_SORTASCENDING + $LVS_EX_FULLROWSELECT + $LVS_EX_GRIDLINES)
GUICtrlSetFont($table, 6, 400, 0, "Verdana")
GUICtrlSetColor(-1, 0x0a0a0a)

$CSV = GUICtrlCreateButton("Export to CSV", 8, 728, 100, 20)
GUICtrlSetState($CSV, $GUI_DISABLE)

$verrors = GUICtrlCreateButton("View Errors", 110, 728, 100, 20)
GUICtrlCreateTabItem("")
GUICtrlSetState($verrors, $GUI_DISABLE)
;audit tab end


;errors tab start
$errortab = GUICtrlCreateTabItem("Errors")
$etable = GUICtrlCreateListView("Computer Name|Error Details|Date & Time", 10, 40, 995, 685, -1, $LVS_SORTASCENDING + $LVS_EX_FULLROWSELECT + $LVS_EX_GRIDLINES)
$eCSV = GUICtrlCreateButton("Export to CSV", 8, 728, 100, 20)
GUICtrlSetState($CSV, $GUI_DISABLE)

GUICtrlCreateTabItem("")
;errors tab end


;settings tab start
$settingstab = GUICtrlCreateTabItem("Settings")
GUICtrlCreateGroup("Target Details", 8, 40, 417, 45)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;individual workstation
;multiple workstations
GUICtrlCreateLabel("Start IP", 16, 60, 96, 17)
$SIP = GUICtrlCreateInput("", 102, 56, 120, 21)

GUICtrlCreateLabel("End IP", 235, 60, 96, 17)
$EIP = GUICtrlCreateInput("", 290, 56, 120, 21)


GUICtrlCreateGroup("Credential", 430, 40, 417, 90)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlCreateLabel("Username:", 446, 56, 121, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$user = GUICtrlCreateInput(@UserName, 567, 54, 273, 21)

GUICtrlCreateLabel("Password:", 446, 80, 121, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$pass = GUICtrlCreateInput("d219642t", 567, 75, 273, 21, $ES_PASSWORD)

GUICtrlCreateLabel("Domain:", 446, 103, 121, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Domain = GUICtrlCreateInput("cramlington", 567, 97, 273, 21)
$go = GUICtrlCreateButton("Process", 855, 45, 145, 70, $WS_GROUP)


GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateTabItem("")
;settings tab end.

GUICtrlSetState($settingstab, $GUI_show)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            MsgBox(64, "Thank you", "Thanks for using Remote Workstation Audit, written by Richard Easton 2011.", 5)
            Exit
        Case $verrors
            _GUICtrlTab_SetCurFocus($tabz, 1)

        Case $CSV
            $output = _guictrlListView_CreateArray($table)
            $file = FileSelectFolder("Please Select the location for your .csv", "")
            $date = @MDAY & @MON & @YEAR
            If @error Then
                MsgBox(48, "RW Auditor", "No File(s) chosen")
            Else
                FileWriteLine($file & "\audit_" & $date & ".csv", "Computer Name,IP Address,Mac Address,Serial Number,Type,Make,Model,CPU Type & Speed,CPU Cores,Memory (MB),HDD size(GB),Operating System,ServicePack")
                _guictrllistview_savecsv($output, $file & "\audit_" & $date & ".csv")
                MsgBox(64, "Audit Output", "your audit file is located in " & $file)
            EndIf

        Case $eCSV
            $output = _guictrlListView_CreateArray($etable)
            $file = FileSelectFolder("Please Select the location for your .csv", "")
            $date = @MDAY & @MON & @YEAR
            If @error Then
                MsgBox(48, "RW Auditor", "No File(s) chosen")
            Else
                FileWriteLine($file & "\auditerrors_" & $date & ".csv", "Computer Name,Error Details,Date & Time")
                _guictrllistview_savecsv($output, $file & "\auditerrors_" & $date & ".csv")
                MsgBox(64, "Audit Errors Output", "your audit file is located in " & $file)
            EndIf

        Case $go



            _GUICtrlTab_SetCurFocus($tabz, 0)
            If Not FileExists($error_log) Then
                DirCreate(@ScriptDir & "\Errorlogs")
                FileWriteLine($error_log, "Error Logs created")
            EndIf

            If GUICtrlRead($SIP) = "" Or GUICtrlRead($EIP) = "" Then
                MsgBox(48, "Warning!", "There is a problem with the IP range selected or one of the credentials are missing!", 10)
            Else
                GUICtrlSetState($audittab, @SW_SHOW)
                $p = 0
                $n = 1
                $ep = 0
                $ap = 0
                $splitstartip = StringSplit(GUICtrlRead($SIP), ".")
                $splitendip = StringSplit(GUICtrlRead($EIP), ".")
                $cip1 = $splitstartip[1]
                $cip2 = $splitstartip[2]
                $cip3 = $splitstartip[3]
                $cip4 = $splitstartip[4]
                $eip3 = $splitendip[3]
                $x = 255
                $y = $eip3 - $cip3
                $z = $y * 255
                GUICtrlSetData($oftotal, $z)
                Do
                    $WSIP = $cip1 & "." & $cip2 & "." & $cip3 & "." & $cip4
                    $var = Ping($WSIP, 250)

                    If $var Then
                        GUICtrlSetData($lblCW, $WSIP, "")
                        GUICtrlSetData($currentnumber, $n, "")
                        If @error Then _IEErrorHandlerRegister("MyErrFunc")


                        ;output.
                        _IEErrorHandlerRegister("MyErrFunc")
                        $objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
                        If Not IsObj($objSWbemLocator) And @error Then
                            _IEErrorHandlerRegister("MyErrFunc")
                        EndIf

                        _IEErrorHandlerRegister("MyErrFunc")

                        $objSWbemServices = $objSWbemLocator.ConnectServer($WSIP, "root\cimv2", GUICtrlRead($Domain) & "\" & GUICtrlRead($user), GUICtrlRead($pass))
                        If IsObj($objSWbemServices) And Not @error Then



                            $objSWbemServices.Security_.ImpersonationLevel = 3

                            ;Computer System
                            $colItems = $objSWbemServices.ExecQuery("select * from Win32_ComputerSystem")
                            If IsObj($colItems) Then
                                For $objItem In $colItems
                                    $pmem = $objItem.TotalPhysicalMemory
                                    $Name = $objItem.name
                                    $make = $objItem.Manufacturer
                                    $Model = $objItem.Model
                                Next
                            EndIf
                            $mem = Round(($pmem / 1024 / 1024), 0)

                            ;chassis type
                            $colChassis = $objSWbemServices.ExecQuery("Select * from Win32_SystemEnclosure")
                            If IsObj($colItems) Then
                                For $objItem In $colChassis
                                    For $Type In $objItem.ChassisTypes

                                        If $Type = 8 Or $Type = 9 Or $Type = 10 Or $Type = 11 Or $Type = 12 Or $Type = 14 Or $Type = 18 Or $Type = 21 Then
                                            $ctype = "Laptop"
                                        ElseIf $Type = 3 Or $Type = 4 Or $Type = 5 Or $Type = 6 Or $Type = 7 Or $Type = 15 Or $Type = 16 Then
                                            $ctype = "Desktop"
                                        ElseIf $Type = 23 Then
                                            $ctype = "Server"
                                        EndIf
                                    Next
                                Next
                            EndIf

                            ;Mac Address
                            $colItems = $objSWbemServices.ExecQuery("select * from Win32_NetworkAdapter")
                            If IsObj($colItems) Then
                                For $objItem In $colItems
                                    $mac = $objItem.MACAddress
                                Next
                            EndIf

                            ;Bios
                            $colItems = $objSWbemServices.ExecQuery("select * from Win32_BIOS")
                            If IsObj($colItems) Then
                                For $objItem In $colItems
                                    $SN = $objItem.SerialNumber
                                Next
                            EndIf

                            ;CPU
                            $colItems = $objSWbemServices.ExecQuery("select * from Win32_Processor")
                            If IsObj($colItems) Then
                                For $objItem In $colItems
                                    $CPU = $objItem.Name
                                    $Cores = $objItem.NumberofCores
                                Next
                            EndIf

                            ;Operating System
                            $colItems = $objSWbemServices.ExecQuery("select * from Win32_OperatingSystem")
                            If IsObj($colItems) Then
                                For $objItem In $colItems
                                    $OS = $objItem.Caption
                                    $SP = $objItem.CSDVersion
                                Next
                            EndIf

                            ;Operating System
                            $colItems = $objSWbemServices.ExecQuery("select * from Win32_DiskDrive")
                            If IsObj($colItems) Then
                                For $objItem In $colItems
                                    $HDDSize = Round(($objItem.Size / 1024 / 1024 / 1024), 0)
                                Next
                            EndIf

                            $datawrite = GUICtrlCreateListViewItem($Name & "|" & $WSIP & "|" & $mac & "|" & $SN & "|" & $ctype & "|" & $make & "|" & $Model & "|" & $CPU & "|" & $Cores & "|" & $mem & "|" & $HDDSize & "|" & $OS & "|" & $SP, $table)
                            GUICtrlSetFont($datawrite, 8, 400, 0, "Verdana")
                            $ap = $ap + 1
                            GUICtrlSetData($audittab, "Audit (" & $ap & ")")
                        EndIf
                    Else
                        If Not FileExists($error_log) Then
                            DirCreate(@ScriptDir & "\Errorlogs")
                            FileWriteLine($error_log, "Error Logs created")
                        EndIf
                        FileWriteLine($error_log, $WSIP & @error)

                        If @error = 0 Then
                            $tCur = _Date_Time_GetSystemTime()
                            GUICtrlCreateListViewItem($WSIP & "|Not responding to a ping request|" & _Date_Time_SystemTimeToDateTimeStr($tCur), $etable)
                            $ep = $ep + 1
                            GUICtrlSetData($errortab, "Errors (" & $ep & ")")
                        Else
                            GUICtrlCreateListViewItem($WSIP & "|" & @error & "|" & _Date_Time_SystemTimeToDateTimeStr($tCur), $etable)
                            $ep = $ep + 1
                            GUICtrlSetData($errortab, "Errors (" & $ep & ")")
                        EndIf
                    EndIf
                    $n = $n + 1
                    $cip4 = $cip4 + 1
                    If $cip4 = 256 Then
                        $cip3 = $cip3 + 1
                        $cip4 = 4
                    EndIf
                    _IEErrorHandlerDeRegister()

                Until $WSIP = GUICtrlRead($EIP)
                If $ep > 0 Then
                    MsgBox(48, "Remote Spec Audit", "Audit completed with errors")
                    GUICtrlSetState($verrors, $GUI_ENABLE)
                    GUICtrlSetState($eCSV, $GUI_ENABLE)
                Else
                    MsgBox(48, "Remote Spec Audit", "Audit completed successfully")
                EndIf

            EndIf
            GUICtrlSetState($CSV, $GUI_ENABLE)



    EndSwitch
WEnd


Func MyErrFunc()
    $tCur = _Date_Time_GetSystemTime()
    GUICtrlCreateListViewItem($WSIP & "|" & $oIEErrorHandler.windescription & "|" & _Date_Time_SystemTimeToDateTimeStr($tCur), $etable)
    $ep = $ep + 1
    GUICtrlSetData($errortab, "Errors (" & $ep & ")")
    SetError(1) ; something to check for when this function returns
EndFunc   ;==>MyErrFunc

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

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