+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
Web Development Thread, Computer Inventory in Coding and Web Development; Thanks to FN-GM for the initial VBS script from this thread This PHP web frontend just shows a list of ...
  1. #1
    zag
    zag is offline
    zag's Avatar
    Join Date
    Mar 2007
    Posts
    3,762
    Thank Post
    897
    Thanked 416 Times in 350 Posts
    Blog Entries
    12
    Rep Power
    86

    Computer Inventory

    Thanks to FN-GM for the initial VBS script from this thread

    This PHP web frontend just shows a list of all the computers on your network with icons and stuff.

    Features
    - Shows Computer Name
    - Shows Computer Manufacturer Brand Logo
    - Shows RAM/HDD/CPU
    - Shows red warning when hard disk under 10gb
    - Shows CPU icon
    - Shows SSD or HDD icon

    Instructions
    If you have a CSV already created from the above vbs script, just copy it to the /CSV folder to see it working.
    Otherwise read the instructions in the readme file.

    Source
    GitHub

    Screenshots
    inventory.png

  2. 2 Thanks to zag:

    FN-GM (17th October 2013), sted (17th October 2013)

  3. #2


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 852 Times in 731 Posts
    Rep Power
    294
    oooh ive been meaning to look into that for my own similar script would it be possible to alter it myself or would you be willing to have a look (again mine pulls to csv but i suspect in different orders and quite possibly different info (it also writes to the description field in ad))

  4. #3
    zag
    zag is offline
    zag's Avatar
    Join Date
    Mar 2007
    Posts
    3,762
    Thank Post
    897
    Thanked 416 Times in 350 Posts
    Blog Entries
    12
    Rep Power
    86
    Yeh its all configurable, there is a settings.php file you can choose a few basic options.

    Otherwise just change the $data variable to the field you want to see.

    I'll make an extra page for networking data such as MAC + IP soon. Then maybe an asset page which will show the Serial number and model.

  5. Thanks to zag from:

    sted (17th October 2013)

  6. #4


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 852 Times in 731 Posts
    Rep Power
    294
    to the notepad++ cave lol

  7. Thanks to sted from:

    zag (17th October 2013)

  8. #5


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 852 Times in 731 Posts
    Rep Power
    294
    if it helps my scripy collects if it saves you from altering yours

    WIN81-01 Hewlett-Packard - Compaq 610 Intel(R) Core(TM)2 Duo CPU T5870 @ 2.00GHz 3072 MB 297 GB 281 GB serial no Microsoft Windows 8.1 Enterprise sp 0 00:00:00:00:00:00 Overall -0 - CPU - 0 - Memory - 0 - Graphics - 0 - Gaming graphics - 0 - hdd - 0 user 100 Mbps-54 Mbps- 16/10/2013

  9. #6

    Join Date
    Apr 2010
    Posts
    2,032
    Thank Post
    82
    Thanked 187 Times in 154 Posts
    Rep Power
    83
    @sted - let me know if you add this to your script, as that is the one I have used.

  10. #7


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 852 Times in 731 Posts
    Rep Power
    294
    im going to have a go when i get time i suspect next week depends if i want to work outside work

  11. #8

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,821
    Thank Post
    873
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    @zag good job!

  12. #9
    SovietRussia's Avatar
    Join Date
    Mar 2013
    Location
    Powys, Wales
    Posts
    606
    Thank Post
    67
    Thanked 131 Times in 102 Posts
    Rep Power
    43
    I built a whole suite of PC and Network Management tools, the Devices tab runs through AD and grabs the devices, then uses WMI to update them, also pings them to check servers are online etc.

    enet.jpg

  13. #10
    zag
    zag is offline
    zag's Avatar
    Join Date
    Mar 2007
    Posts
    3,762
    Thank Post
    897
    Thanked 416 Times in 350 Posts
    Blog Entries
    12
    Rep Power
    86
    That looks cool @SovietRussia but I prefer web stuff myself.

    I've just commited some changes to add an Assets page and a Network page.

    No more searching for MAC addresses yey!

  14. #11


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 852 Times in 731 Posts
    Rep Power
    294
    right been having a play using my script as input. Initial tests say it works fine (by initial ive copy and pasted my data into the example sheet) so in theory all i need to do is alter the $name=$data[3] to match my output but the provided script was writen to ignore column 1 (and everything else seems to be ofset by 1 (so to read collumn 3 you tell it to read collumn 4) it is probably just a case of altering the output of my scriptto more closely match (or if im being really lazy insert blank colums so it exactly matches which actually may be a better idea incase zag updates it it should then just work still) My main issue is atm my script generates 1 file per pc rather than one file total so i would need to alter that (but im of a mind to leave my 1 file for pc as well just have it make 2 files)

    also minor issue i tried to add a toshiba icon to serttings but it just keeps telling me the file is open even with iis stopped any way round this? (sorry i dont use iis much and it probably dosent help im running it on a win7 box for testing)

  15. #12


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 852 Times in 731 Posts
    Rep Power
    294
    right rigged my script to deliver its output in the same format as the included one.

    What i cant work out atm is

    1. how to get it to write one file for lots of pcs without ending up with the same machine on multiple lines everytime the script runs
    2. how to get vbs to make a 2nd file (my script has info i want the enclosed one dosent detect and vice versa)

  16. #13


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 852 Times in 731 Posts
    Rep Power
    294
    @edutech4schools i now have a version of my script thats compatible.

    As my script and zags collect different info and deal with it differently ive made it so that it creates the same (roughly as i keep making minor tweeks to the output as needed most recently for mdt i slightly altered the "make model" to "make-model") ive made it so that it creates a single file for each pc the (same as always), adds selected info to the ad description field (same as always) but now creates a combined file in the same format as zags (granted thats by adding lots of blank fields but it works as some of the info zags script collects just dosent interest me and some it dosent does) this is saved as one contiguous file so every time pc01 say runs it deletes its entry from the csv then readds itself at the bottom.

    As always with any scripts it seems to work for me and hasnt caused me any issues but if it breaks something i take no responsibility (and i only finished it 30 mins or so ago)

    Code:
    Option Explicit
    'On Error Resume Next
    
    dim outputstring, computermodel, pcmake, pcmodel, cpu, ram, hddcapacity, hddfree, serialno, macaddress, operatingsystem, csvoutput, csvoutput2
    dim stcomputer, colitems, objItem, colcpu, colPhysicalMemory, objPhysicalMemory, intMemory, colDisks, objhdd
    dim colComputerSystem, colOperatingSystems, objOperatingSystem, colBIOS, objBIOS, colnicconfig, objnicconfig
    dim objwmiservice, hddtemp, weidata, colWSA, operatingsystemno, Lastuser, oreg, spath, svalue, strvalue, svaluename
    dim adoutputstring, adoRecordset, adoConnection, objRootDSE, objNetwork, objComputer, existing, basedata
    dim pcname, wshShell, strDirectory, strFile, objFSO, objFolder, objFile, objTextFile, myDateString
    dim colnet,objnet, linkspeed, objWMIService2, strline, strNewContents, strDirectory2, strFile2, objfolder2, objfile2
    
    stcomputer = "."
    myDateString = Date()
    
    Set objRootDSE = GetObject("LDAP://RootDSE")
    Set objNetwork = WScript.CreateObject("WScript.Network")
    Set objWMIService = GetObject("winmgmts:\\" & stcomputer & "\root\CIMV2") 
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") 
    Set colcpu = objWMIService.ExecQuery("Select * from Win32_Processor")
    Set colPhysicalMemory = objWMIService.ExecQuery("Select * From Win32_PhysicalMemory")
    set coldisks = objWMIService.ExecQuery("Select * From Win32_LogicalDisk") 
    Set colComputerSystem = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
    Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    Set colBIOS = objWMIService.ExecQuery("Select * From Win32_BIOS")
    Set colnicconfig = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    Set colWSA = objWMIservice.ExecQuery("Select * From Win32_WinSAT")
    Set adoConnection = CreateObject("ADODB.Connection")
    adoConnection.Provider = "ADsDSOObject"
    adoConnection.Open "Active Directory Provider"
    Set adoRecordset = adoConnection.Execute("<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">;(&(objectCategory=Computer)(name=" & objNetwork.Computername & "));adspath;subtree")
    Set wshShell = WScript.CreateObject( "WScript.Shell" )
    Set objWMIService2 = GetObject("winmgmts:\\" & stComputer & "\root\WMI")
    Set colnet = objWMIService2.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)
    basedata= "MAC Address,Network Adapter,IP Address,Computer Name,GUID/UUID,GUID/UUID Mac Address Conversion,Total RAM Memory,Sid,RAM Memory Bank Label,RAM Memory Capacity,RAM Memory Device Locator,RAM Memory Manufacturer,Computer Manufacturer,Computer Model,Computer Serial,Motherboard Manufacturer,Motherboard Model,Motherboard Product,Motherboard Serial Number,Motherboard Version,Hard Disk Drive Letter,Hard Disk Size,Hard Disk Free Space,Hard Disk Volume Serial Number,Hard Disk Manufacturer,Hard Disk Model,Hard Disk Device ID,Hard Disk Interface Type,Hard Disk Partitions,Hard Disk Total Cylinders,Hard Disk Total Heads,Hard Disk Total Sectors,Hard Disk Total Tracks,Hard Disk Tracks Per Cylinder,Processor Name,Processor Type,Processor Family,Sound Card Manufacturer,Sound Card Product Name,Sound Card Description,Sound Card Name,Video Card Name,Video Card Setting ID,Floppy Manufacturer,Floppy Name,Floppy Device ID,CDROMCaptionSet,CDROMDescriptionSet,CDROMDeviceIDSet,CDROMDriveSet,CDROMManufacturerSet,CDROMNameSet,BIOS Version,Dell Service Tag,Date of Log,Time of Log"
    'write file 1 location
    pcname = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
    strDirectory = "\\server\logs$\pc2\"
    strFile = pcname & ".csv"
    
    'write file 2 location
    
    strDirectory2 = "\\server\inventory$\"
    strFile2 = "inventorylog.csv"
    
    
    'make-model
    For Each objItem In colItems 
    	computermodel= objItem.Manufacturer & " " & objItem.Model
    	pcmake=objItem.Manufacturer
    	pcmodel=objItem.Model
    	'wscript.echo computermodel
    Next
    
    ' Create the File System Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    'cpu info
    For Each objItem in colcpu
        cpu = objItem.Name
    	'wscript.echo cpu
    Next
    
    'ram
    If Not colPhysicalMemory Is Nothing Then
    	 intMemory = 0
    	 For Each objPhysicalMemory In colPhysicalMemory
    		 intMemory = intMemory + Int(objPhysicalMemory.Capacity)
    	 Next
    	 ram = (intMemory / 1024 / 1024 ) & " MB"
    	 'wscript.echo ram
    End If
    
    'hdd capacity
    for each objhdd in coldisks
    	If objhdd.DeviceID = "C:" Then
    		hddcapacity = int(objhdd.Size/1073741824) & " GB"
    		hddfree = int(objhdd.freespace/1073741824) & " GB"
    		'wscript.echo hddfree
    	end if
    next
    
    'windows version
    For Each objOperatingSystem in colOperatingSystems
        operatingsystem = objOperatingSystem.Caption & " sp " & objOperatingSystem.ServicePackMajorVersion
    	operatingsystemno = objOperatingSystem.Version
    		'wscript.echo operatingsystem
    	Next
    
    'serial no
    If Not colBIOS Is Nothing Then
    	 For Each objBIOS in colBIOS
    		 serialno = objBIOS.SerialNumber
    		 'wscript.echo serialno
    	 Next
    End If
    
    'mac address(s)
    If Not colnicconfig Is Nothing Then
    	 For Each objnicconfig in colnicconfig
    		 If macaddress <> "" Then
    			 macaddress = macaddress & " - "
    		 End If
    		 macaddress = macaddress & objnicconfig.MACAddress
    		 'wscript.echo macaddress
    	 Next
    End If
    
    'windows experience
    operatingsystemno = Left( operatingsystemno, 3 )  
    if operatingsystemno >5.5 then
    	'vista+
    	For Each objItem in colWSA
    	'weidata = "Overall -" & "na" & " - CPU - " & "na" & " - Memory - " & "na" & " - Graphics - " & "na" & " - Gaming graphics - " & "na" & " - hdd - " & "na" 
    		weidata = "Overall -" & objItem.WinSPRLevel & " - CPU - " & objItem.CPUScore & " - Memory - " & objItem.MemoryScore & " - Graphics - " & objItem.GraphicsScore & " - Gaming graphics - " & objItem.D3DScore & " - hdd - " & objItem.DiskScore
    	next
    else
    	'xp-
    	weidata = "Overall -" & "na" & " - CPU - " & "na" & " - Memory - " & "na" & " - Graphics - " & "na" & " - Gaming graphics - " & "na" & " - hdd - " & "na" 
     end if
    
     'last user
     if operatingsystemno >5.5 then  
    	'vista+
    	Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
    	Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & stcomputer & "/root/default:StdRegProv")
    	If Err.Number <> 0 Then
    		On Error Goto 0
    	Else
    		On Error Goto 0
    		sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI"
    		sValueName = "LastLoggedonUser"
    		If oReg.GetStringValue(HKLM, sPath, sValueName, sValue) = 0 Then
    			lastuser = sValue
    		Else
    			lastuser = "unknown" & stcomputer
    		End If
    	End If
    else
    	'xp-
    	Const HKEY_LOCAL_MACHINE = &H80000002
    	Set oreg=GetObject("winmgmts:\\" & stComputer & "\root\default:StdRegProv")
    	spath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon"
    	svalue = "DefaultUserName"
    	oreg.GetStringValue HKEY_LOCAL_MACHINE, spath, svalue, strValue
    	lastuser=strvalue
    	svalue = "DefaultDomainName"
    	oreg.GetStringValue HKEY_LOCAL_MACHINE, spath, svalue, strValue
    	lastuser = strvalue & "\" & lastuser
    end if
     
     'Scans data for Net Speed
    For Each objnet in colnet
    
    'Removes "slow/unused links"
    if objnet.NdisLinkSpeed/10 > 1000 then
    	linkspeed= objnet.NdisLinkSpeed/10000 & " Mbps" & "-" & linkspeed '& "-" & objnet.NdisLinkSpeed/10000 & " Mbps"
    end if
    next
     
    'concatanate data for output
    outputstring = computermodel & "," & cpu &"," & ram &"," & hddcapacity& ","  & serialno & "," & macaddress & "," 
    csvoutput = pcname & "," & computermodel & "," & cpu &"," & ram &"," & hddcapacity& "," & hddfree & "," & serialno & "," & operatingsystem & "," & macaddress & "," & weidata & "," & Lastuser & "," & linkspeed &"," & myDateString &","
    csvoutput2 = macaddress & ", "&" ,"& "," & pcname & "," & "," & "," & ram &"," &"," &"," &"," &"," &"," & pcmake & "," & pcmodel & "," & serialno & ","  & "," & "," & "," & "," & "," & "," & hddcapacity & "," & hddfree & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & cpu & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "dell," & myDateString & ","
    ' wscript.echo outputstring
    
    ' Check that the strDirectory folder exists
    If objFSO.FolderExists(strDirectory) Then
       Set objFolder = objFSO.GetFolder(strDirectory)
    Else
       Set objFolder = objFSO.CreateFolder(strDirectory)
       'WScript.Echo "Just created " & strDirectory
    End If
    
    If objFSO.FileExists(strDirectory & strFile) Then
       Set objFolder = objFSO.GetFolder(strDirectory)
    Else
       Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
       'Wscript.Echo "Just created " & strDirectory & strFile
    End If 
    
    set objFile = nothing
    set objFolder = nothing
    ' OpenTextFile Method needs a Const value
    ' ForAppending = 8 ForReading = 1, ForWriting = 2
    Const ForAppending = 2
    
    Set objTextFile = objFSO.OpenTextFile _
    (strDirectory & strFile, ForAppending, True)
    
    ' Writes result every time you run this VBScript
    objTextFile.WriteLine(csvoutput)
    objTextFile.Close
    
    If Err.Number <> 0 Then
    	 MsgBox "Query Error: " & Err.Description
    	 WScript.Quit
    End If
    '********************************************
    '2nd file
    '********************************************
    
    
    ' Check that the strDirectory folder exists
    If objFSO.FolderExists(strDirectory2) Then
       Set objFolder2 = objFSO.GetFolder(strDirectory2)
    Else
       Set objFolder2 = objFSO.CreateFolder(strDirectory2)
       'WScript.Echo "Just created " & strDirectory2 & strfile2 & "bit1"
    End If
    
    If objFSO.FileExists(strDirectory2 & strFile2) Then
       Set objFolder2 = objFSO.GetFolder(strDirectory2)
    Else
       Set objFile2 = objFSO.CreateTextFile(strDirectory2 & strFile2)
       'Wscript.Echo "Just created " & strDirectory2 & strFile2 &"bit2"
       objfile2.close
       Set objFile2 = objFSO.OpenTextFile((strDirectory2 & strFile2), ForWriting)
       objFile2.WriteLine(basedata)
       objfile2.close
    End If 
    
    Const ForReading = 1
    Const ForWriting = 2
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile2 = objFSO.OpenTextFile((strDirectory2 & strFile2), ForReading)
    
    Do Until objFile2.AtEndOfStream
        strLine = objFile2.ReadLine
        If InStr(left(strLine,17), macaddress) = 0 Then
            strNewContents = strNewContents & strLine & vbCrLf
        End If
    Loop
    
    objFile2.Close
    
    Set objFile2 = objFSO.OpenTextFile((strDirectory2 & strFile2), ForWriting)
    objFile2.Write strNewContents
    objFile2.WriteLine(csvoutput2)
    
    objFile2.Close
    
    If Not adoRecordset.EOF Then
    	 Set objComputer = GetObject(adoRecordset.Fields(0).Value)
    	 existing = objcomputer.Description
    	 if left (existing,1) = "#" and not right (existing,1) = "#" then outputstring = existing & " : " & outputstring & "#"
    	 if left (existing,1) = "#" and right (existing,1) = "#" then
    		'msgbox "data"
    		wscript.quit
    	end if
    if not objComputer.Description = outputstring then
    		'msgbox "diff"
    		objComputer.Put "description", outputstring
    		objComputer.SetInfo
    	else
    		'msgbox "matches"
    	 end if
    	  
    End If
    
    If Err.Number <> 0 Then
    	 MsgBox "Write Error: " & Err.Description
    	 WScript.Quit
    End If

  17. Thanks to sted from:

    zag (24th October 2013)

  18. #14


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 852 Times in 731 Posts
    Rep Power
    294
    back again lol

    being having a play with this again now (currently on v5 of my script and v2 of the index.php lol) So far ive succesfully added serial no and windows version (as text) to the web page. Now as my php is minimal is it possible to edit it in someway to display a logo for windows version rather than an image like it does for manufacturer so i can have say a big 7e pic for windows 7 enterprise and so on as the text is quite long and an icon would be quicker to process. I suspect looking at the images folder it was doing this (or was thought about) at some stage

    also the hdd free always seems to show red even when its 200gb free any ideas? i suspect its probably the way i gather it as 14 GB
    Last edited by sted; 6th November 2013 at 10:06 AM.

  19. #15
    zag
    zag is offline
    zag's Avatar
    Join Date
    Mar 2007
    Posts
    3,762
    Thank Post
    897
    Thanked 416 Times in 350 Posts
    Blog Entries
    12
    Rep Power
    86
    The original VBS script didnt check Operating System unfortunately so I never included it.

    It should be easy to copy and paste the code to add it though.

    We're Windows 7 all round here so not really much point for me to add this.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. OCS Inventory
    By Geoff in forum Downloads
    Replies: 5
    Last Post: 3rd June 2011, 08:40 AM
  2. Replies: 1
    Last Post: 17th January 2011, 02:36 PM
  3. computer inventory
    By itgeek in forum Wireless Networks
    Replies: 10
    Last Post: 18th November 2010, 02:51 PM
  4. Computer And Software Inventory!! HELP!
    By joshjacklin in forum Network and Classroom Management
    Replies: 12
    Last Post: 2nd August 2010, 09:09 AM
  5. Computer keeps crashing
    By StewartKnight in forum Windows
    Replies: 15
    Last Post: 18th July 2005, 09:54 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •