Jump to content

Computer Inventory Project


Recommended Posts

Hello all,

I'm "new" to AutoIt in the sense that I only ever really use it, to do simple things, like logging into remote PC's, websites and such.

Now my work needs to inventory over 700 PCs that we have, we need to know

1. OS + Service Pack

2. RAM installed

3. Installed Software

4. All Binded Ip's

5. Hard Drive Space/ Total and Available

6. Computer Name

I have found several "free" programs that will do this but they all require the program to be installed on the production machines. Which isn't an option.

I need a script that basically will pull this info and either dump it to a .txt file, or preferably email me the results, in a nice looking format.

I'm more than willing to learn how to do this using autoit, but I need some help on where I should get started and if this can be done.

My actual programming knowledge is very very small.

Thanks in Advance for any help.

Link to comment
Share on other sites

  • Developers

Is it possible to have these PC's run a Script via the login script or at startup ?

When that is the case its not too difficult to create a script and have it mail all this information one time into a Mailbox.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

hmm the problem with the "startup" portion is that these are our customers machines, we are a web hosting company.

Login script may be feasible.

I take it this question has been asked here before due to the quick answer

Link to comment
Share on other sites

  • Developers

hmm the problem with the "startup" portion is that these are our customers machines, we are a web hosting company.

Login script may be feasible.

I take it this question has been asked here before due to the quick answer

I have done something like this at my previous work. It was a script running daily at first startup and would only send out an Email when the Users suddenly had Admin level access or their AV definitions would be older than 5 days.

It would also give info on Pcname, OS/SP, Username, IPaddress etc.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

well the good news is I only need to do this once. But i figure it would be an awesome way to show what I can really do with autoit.

I just need some help with how I should begin scripting this. Also I've never created a gui either but I guess a gui for this purpose would be kind of pointless.

Link to comment
Share on other sites

Well, at my job, we recently had a need for a script to get similar information for us (and by need, I mean I was told to get the info, and didn't want to run all around creation looking for it). I handled it differently. I researched the WMI methods, and made a script that can remotely poll computers for me. Since we have a domain at work, I can give the script an Admin account credentials, and pull information from a number of computers fairly quick. I've been meaning to polish it up some, and post it here, to show how a lot of the advanced tricks work. If your interested, I could go ahead with what I've got, when I make it to work Monday.

Link to comment
Share on other sites

Well, at my job, we recently had a need for a script to get similar information for us (and by need, I mean I was told to get the info, and didn't want to run all around creation looking for it). I handled it differently. I researched the WMI methods, and made a script that can remotely poll computers for me. Since we have a domain at work, I can give the script an Admin account credentials, and pull information from a number of computers fairly quick. I've been meaning to polish it up some, and post it here, to show how a lot of the advanced tricks work. If your interested, I could go ahead with what I've got, when I make it to work Monday.

Thats pretty much exactly what I need to do. Yeah if you wouldn't mind sharing what you have that would be cool.

Link to comment
Share on other sites

Hello all,

I'm "new" to AutoIt in the sense that I only ever really use it, to do simple things, like logging into remote PC's, websites and such.

Now my work needs to inventory over 700 PCs that we have, we need to know

1. OS + Service Pack

2. RAM installed

3. Installed Software

4. All Binded Ip's

5. Hard Drive Space/ Total and Available

6. Computer Name

Not an Autoit answer per say but take a look at the Sysinternal's pstools

Pstools @ Microsoft's Techweb site

They can do that type of stuff

For example the following code gathered the hot fix'es installed on my moms machine upstairs opened it in notepad as soon as it was done

RunWait('"' & @ComSpec & '" /c psinfo -h \\192.168.0.133 > C:\GatheredInfo\HotfixList133.txt', '', @SW_HIDE)

While True
    If FileExists ('C:\GatheredInfo\HotfixList133.txt') Then
        Run('notepad.exe C:\GatheredInfo\HotfixList133.txt')
        ExitLoop
    EndIf
    Sleep(500)
WEnd
Link to comment
Share on other sites

  • Developers

Not an Autoit answer per say but take a look at the Sysinternal's pstools

Pstools @ Microsoft's Techweb site

They can do that type of stuff

For example the following code gathered the hot fix'es installed on my moms machine upstairs opened it in notepad as soon as it was done

RunWait('"' & @ComSpec & '" /c psinfo -h \\192.168.0.133 > C:\GatheredInfo\HotfixList133.txt', '', @SW_HIDE)

While True
    If FileExists ('C:\GatheredInfo\HotfixList133.txt') Then
        Run('notepad.exe C:\GatheredInfo\HotfixList133.txt')
        ExitLoop
    EndIf
    Sleep(500)
WEnd
Just wondering here why you have that While-Wend loop there? Doesn't the RunWait wait till psinfo is finished?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I wrote SIC2 which is a command line tool to collect a lot of data using pseudo multi threading (maybe not the best way) from

systems all over the network.

If you are not afraid to use command line then have a look on it (see below to my signature for more information)!

It is free for personal use ^_^

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

CODE

Dim $computername = @ComputerName ; Computer Name

Dim $OS = @OSVersion ; OS Version

Dim $Processor = @ProcessorArch

Dim $ServicePack = @OSServicePack

Dim $mem = MemGetStats()

Dim $NIC1 = @IPAddress1

Dim $NIC2 = @IPAddress2

Dim $NIC3 = @IPAddress3

Dim $NIC4 = @IPAddress4

Dim $text = ""; Output text for message box.

Dim $text1 = ""

Dim $text2 = ""

Dim $text3 = ""

Dim $text4 = ""

Dim $text5 = ""

Dim $text6 = ""

Dim $text7 = ""

Dim $text8 = ""

Switch $OS ; A Switch statement. We are going to make the value returned by

@OSVERSION more readable.

Case "WIN_2008"

$OS = "Windows Server 2008"

Case "WIN_VISTA"

$OS = "Windows Vista"

Case "WIN_2003"

$OS = "Windows Server 2003"

Case "WIN_XP"

$OS = "Windows XP"

Case "WIN_2000"

$OS = "Windows 2000"

Case "WIN_NT4"

$OS = "Windows NT 4.0"

Case "WIN_ME"

$OS = "Windows ME"

Case "WIN_98"

$OS = "Windows 98"

Case "WIN_95"

$OS = "Windows 95"

Case Else

$OS = "Windows 7"

EndSwitch

$text &= "Computer Name = " & $computername & @CRLF

$text1 &= ($mem[1])

$text2 &= "OSVersion = " & $OS & @CRLF

$text3 &= "Service Pack = " & $ServicePack & @CRLF

$text4 &= "Processor = " & $Processor & @CRLF

$text5 &= "IP Address 1 = " & $NIC1 & @CRLF

$text6 &= "IP Address 2 = " & $NIC2 & @CRLF

$text7 &= "IP Address 3 = " & $NIC3 & @CRLF

$text8 &= "IP Address 4 = " & $NIC4 & @CRLF

Run ("notepad.exe")

WinWaitActive ("Untitled - Notepad")

Send ($text)

Send ("Installed Memory = ")

Send ($text1)

Send (" mb")

Send("{enter}")

Send("{enter}")

Send ($text2)

Send ($text3)

Send ($text4)

Send ($text5)

Send ($text6)

Send ($text7)

Send ($text8)

Send ("^s")

sleep (2000)

Send ("Inventory.html")

Send("{enter}")

This is what I have so far. i have noticed that the Memory is reporting 917048 mb instead of 1gb. Also, the NIC isn't showing the Default Gateway or Subnet Mask, or DNS. Is there a way to make it pull that information? I'm still having issues trying to get the installed software pulled and reported on this Inventory.html document. I also have another issue, now I have to send this in an email on machines that don't have an email client installed. I know that you can send emails via DOS, but can you send emails with attachments?

Thanks for anyone who can help in this matter.

atnextc

Link to comment
Share on other sites

Why don't you make it run behind the scenes instead of opening notepad.

Something like this:

$file = ("c:\Compinfo.txt")

$file2 = FileOpen($file, 1)

FileWriteLine($file, $text1)

FileClose($file)

Run("notepad.exe "&$File)

OR, this will probably work:

$file = ("c:\Compinfo.txt")

$file2 = FileOpen($file, 1)

FileWriteLine($file, $text1)

FileWriteLine($file, $text2)

FileWriteLine($file, $text3)

FileWriteLine($file, $text4)

FileWriteLine($file, $text5)

FileClose($file)

Run("notepad.exe "&$File)

Link to comment
Share on other sites

INstead of the part that opens notepad, then waits for it, then outputs it all into notepad and saves it. This would be also better because it could run in the background, and would save automatically. Just a though. Your way works too, just if someone clicks off the screen for a second, it will screw up the script.

Link to comment
Share on other sites

Run ("C:\siw.exe" @SW_HIDE)
Sleep (5000)
$number = InputBox("Company Inventory", "Enter Server Name To Inventory", "")
Sleep (1000)
MouseMove (16,35)
Sleep (1000)
MouseClick ("Left")
MouseMove (75,125)
Sleep (1000)
MouseMove (216,130)
Sleep (1000)
MouseClick ("Left")
MouseMove (629,633)
Sleep (3000)
MouseClick ("Left")
Send ($number)
Send ("{ENTER}")
Sleep (60000)
WinWaitActive("System Information")
Send ("{ENTER}")
Send ("!FX")
Run(@ComSpec & ' /c "C:\windows\system32\cmd.exe"') 
Run(@ComSpec & ' /c "C:\winnt\system32\cmd.exe"')
Sleep (2000)
Send ("cd \")
Send ("{ENTER}")
Sleep (1000)
Send ("ftp 10.10.10.10")
Sleep (1000)
Send ("{ENTER}")
Sleep (1000)
Send ("user")
Send ("{ENTER}")
Sleep (1000)
Send ("password")
Sleep (1000)
Send ("{ENTER}")
Send ("cd ")
Send ('"Company Inventory"')
Send ("{ENTER}")
Sleep (1000)
Send ("put ")
Send ($number)
Send (".html")
Send ("{ENTER}")
Sleep (10000)
Send ("bye")
Send ("{ENTER}")
Sleep (1000)
Send ("exit")
Send ("{ENTER}")
Sleep (1000)
Run(@ComSpec & ' /c "C:\windows\system32\cmd.exe"') 
Run(@ComSpec & ' /c "C:\winnt\system32\cmd.exe"')
Sleep (1000)
Send ("cd \")
Send ("{ENTER}")
Sleep (1000)
Send ("notepad.exe")
Send ("{ENTER}")
WinWaitActive ("Untitled - Notepad")
Sleep (1000)
Send ("del C:\siw.exe")
Send ("{ENTER}")
Send ("del C:\")
Send ($number)
Send (".html")
Send ("{ENTER}")
Send ("del C:\Inventory2.exe")
Send ("{ENTER}")
Send ("del C:\Inventory2.zip")
Send ("{ENTER}")
Send ("del C:\Inventory.exe")
Send ("{ENTER}")
Send ("del C:\Delete.bat")
Send ("!FS")
Sleep (1000)
Send ("Delete.bat")
Sleep (1000)
Send ("{ENTER}")
Sleep (2000)
Send ("!FX")
Sleep (4000)
Send ("exit")
Send ("{ENTER}")
Sleep (1000)
MsgBox (0, "Company Inventory", "Inventory Is Complete","")
Run ("C:\Delete.bat")

This is what I have ended up with. I want to make it better as it has bugs in it that I can only simulate on other machines, which is a bad thing. I urge someone to take a look and see what I can do to make this better.

I want all of it to be hidden from site of viewer and just have like a progress bar and when its done popup the message stating that inventory is complete. IF i'm just being picky then please let me know. ^_^ Criticism welcome

Link to comment
Share on other sites

Why dont use WMI Query ?

$strComputer = InputBox(" Computer Name", "Insert Computername to Query:", @ComputerName)

$objWMIService = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & $strComputer & "\root\cimv2")
If Not IsObj($objWMIService) Then Exit

; Get Software
$colSoftware = $objWMIService.ExecQuery ("SELECT * FROM Win32_Product")
For $objSoftware in $colSoftware
    ConsoleWrite ($objSoftware.Caption & " " & $objSoftware.Version & @CRLF)
Next    

ConsoleWrite(@CRLF)

;Get Disk
$colDisk = $objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDisk")
For $objDisk in $colDisk
    ConsoleWrite ($objDisk.Name & " " & $objDisk.FileSystem & " Size/Free: " & Int($objDisk.Size /1073741824)  & Int($objDisk.FreeSpace /1073741824) & @CRLF)
Next    

ConsoleWrite(@CRLF)

;Get System
$colItem = $objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For $objItem in $colItem
    ConsoleWrite( $objItem.CSName & " " & $objItem.Caption & " " & $objITem.Version & @CRLF)
Next    

ConsoleWrite(@CRLF)

;Get Ram
$colItem = $objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystem")
For $objItem in $colItem
    ConsoleWrite( "Total RAM " & $objItem.TotalPhysicalMemory & @CRLF)
Next    

ConsoleWrite(@CRLF)

;Get IP
$colAdapters = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For $objAdapter in $colAdapters
   If Not ($objAdapter.IPAddress) = " " Then
      For $i = 0 To UBound($objAdapter.IPAddress)
            ConsoleWrite ("  IP address " & ($i) & ":             " & $objAdapter.IPAddress($i)& @CR)
      Next
   EndIf
NextoÝ÷ Ù6¤y©h¢F­1 ͺ¹
Edited by Tec
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...