Script to extract software inventory from PCs on a network

Discussion in 'Scripting' started by Wizzy, Dec 11, 2007.

  1. Wizzy

    Wizzy Guest

    Hi,

    I am in requirement of a script which would extract all details (name,
    version, etc) of all Micrsoft Softwares/Apps(including patches) installed on
    all the PCs on a domain & also workgroup.
    I will be running the script from a domain admin acct from one of the PCs on
    the domain or workgroup. I understand MSIA is available for this purpose
    however we did not have good sucess rate with it. Also we would like to get
    the machine specific details like name, windows name, version name, processor
    details etc.
    I would be very thankful to anyone who helps me with this as I have an
    urgent audit coming up....!
     
    Wizzy, Dec 11, 2007
    #1
    1. Advertisements

  2. I have an example VBScript program to inventory computers linked here:

    http://www.rlmueller.net/Inventory.htm

    This does not inventory software, but it demonstrates the steps to connect
    to each machine and log the results to a spreadsheet. This example use IE to
    display an interactive message indicating progress. To inventory software
    you can use the Win32_Product class of WMI. You can also use the
    Win32_SoftwareFeature class for even more detail. See this link:

    http://www.microsoft.com/technet/scriptcenter/guide/sas_cpm_dgls.mspx

    Also, this example from the Technet Script Center:

    http://www.microsoft.com/technet/scriptcenter/scripts/apps/user/usapvb06.mspx

    For processor information, see this link:

    http://www.microsoft.com/technet/scriptcenter/scripts/desktop/info/dminvb03.mspx
     
    Richard Mueller [MVP], Dec 11, 2007
    #2
    1. Advertisements

  3. I use the following script:


    ' ***************************************************************************
    ' ***************************************************************************
    ' ***************************************************************************
    ' ************ List of all applications installed on the servers
    ****************
    ' ***************************************************************************
    ' ***************************************************************************
    ' ***************************************************************************

    Const ForReading = 1
    Const ForWriting = 2
    Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

    Dim objFSO, objServerList, strServerName
    Dim strServiceInfo

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objResultFile = objFSO.CreateTextFile("Result.txt", ForWriting)

    ReadServerNames()
    For each strServerName In objServerList
    if strServerName <> "" then
    strServiceInfo = ReadApps(strServerName)
    objResultFile.WriteLine strServiceInfo
    end if
    Next

    objResultFile.Close
    Set objFSO = Nothing
    WScript.Echo "Job complete"
    WScript.Quit(0)

    '****************************************************************
    ' Reading the list of servers
    '****************************************************************
    Function ReadServerNames
    Dim objTextFile

    Set objTextFile = objFSO.OpenTextFile("Servers.txt", ForReading)
    objServerList = Split(objTextFile.ReadAll, vbNewline)
    objTextFile.Close

    End Function

    '****************************************************************
    ' Reading the list of services
    '****************************************************************
    Function ReadApps (ServerName)
    On Error Resume Next
    Dim strLine
    Dim objReg, strKey, arrSubKeys, strValue, intValue

    strLine = ""
    strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

    Set objReg = GetObject("winmgmts://" & ServerName &
    "/root/default:StdRegProv")
    if objReg is nothing then
    strLine = ServerName + ";NO REMOTE REGISTRY SERVICE RUNNING;;;;;" + vbCRLF
    else
    objReg.EnumKey HKLM, strKey, arrSubkeys

    For Each strSubkey In arrSubkeys
    if objReg.GetStringValue(HKLM, strKey & strSubkey, "DisplayName",
    strValue) <> 0 then
    objReg.GetStringValue HKLM, strKey & strSubkey, "QuietDisplayName",
    strValue
    end if
    if strValue <> "" then
    strLine = strLine & ServerName & "|" & strValue
    ' If intRet1 <> 0 Then
    ' objReg.GetStringValue HKLM, strKey & strSubkey, _
    ' strEntry1b, strValue1
    ' End If
    ' If strValue1 <> "" Then
    ' WScript.Echo VbCrLf & "Display Name: " & strValue1
    ' End If
    objReg.GetStringValue HKLM, strKey & strSubkey, "InstallDate", strValue
    strLine = strLine & "|" & strValue
    objReg.GetDWORDValue HKLM, strKey & strSubkey, "VersionMajor", intValue
    strLine = strLine & "|" & intValue
    objReg.GetDWORDValue HKLM, strKey & strSubkey, "VersionMinor", intValue
    strLine = strLine & "." & intValue

    ' If intValue3 <> "" Then
    ' WScript.Echo "Version: " & intValue3 & "." & intValue4
    ' End If
    objReg.GetDWORDValue HKLM, strKey & strSubkey, "EstimatedSize", intValue
    strLine = strLine & "|" & intValue & " MB" & vbCRLF
    ' If intValue5 <> "" Then
    ' WScript.Echo "Estimated Size: " & Round(intValue5/1024, 3) & " megabytes"
    ' End If
    end if
    Next
    end if

    ReadApps = strLine
    End Function
     
    Andrew Karmadanov, Dec 11, 2007
    #3
  4. Wizzy

    krank

    Joined:
    Sep 4, 2010
    Messages:
    1
    Likes Received:
    0
    krank, Sep 4, 2010
    #4
  5. Wizzy

    romans

    Joined:
    Apr 2, 2011
    Messages:
    1
    Likes Received:
    0
    romans, Apr 2, 2011
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.