Script to output installed applications and updates

Reading Time: 2 minutes

This script will scan one or multiple computers by reading the registry, programs and features. It will then output the details into a CSV file. This has been tested on Windows 7 and Server 2008 R2

1) Create a txt file including your machine names or ip addresses e.g. servers.txt

2) Download the script by clicking here

3) Run the script logged in as domain admin

4) The below box will appear. Type in the path to your filename which includes server names or ip addresses. This is the one you created in step 1 above

 

1

5) Click OK, the below window will appear. Type the location you would like the CSV file to be created and application details outputted to. The CSV file will be created by the script.

2

6) Click OK and allow the script to run. Can take a while depending on how many machines require scanning.

7) When done, the below confirmation will appear.

3

8) Check your CSV file for results

Script to list installed software and output to CSV

Reading Time: < 1 minute

The below script will output applications installed on a server/workstation to a CSV file.

Copy the below to a notepad file and name with a .vbs extention e.g. InstalledSoftware.vbs.

Amend the path on line 13 or leave as default. (Note, you may need to re enter the speech ( ” ) marks after copying the below code to a notepad file.

Const HKLM = &H80000002 ‘HKEY_LOCAL_MACHINE
strComputer = “.”
strKey = “SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\”
strEntry1a = “DisplayName”
strEntry1b = “QuietDisplayName”
strEntry2 = “InstallDate”
strEntry3 = “VersionMajor”
strEntry4 = “VersionMinor”
strEntry5 = “EstimatedSize”
Set objShell = CreateObject(“WScript.Shell”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
strTemp = objShell.ExpandEnvironmentStrings(“%TEMP%”)
Set objFile = objFSO.CreateTextFile(“C:\Listsoftware.csv“,True)
Set objReg = GetObject(“winmgmts:{impersonationLevel=delegate}!//” & strComputer & _
 “/root/default:StdRegProv”)
objReg.EnumKey HKLM, strKey, arrSubkeys
 objFile.WriteLine VbCrLf & “Display Name,Install Date,Version,Estimated Size mb”
For Each strSubkey In arrSubkeys
  intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
   strEntry1a, strValue1)
  If intRet1 <> 0 Then
    objReg.GetStringValue HKLM, strKey & strSubkey, _
     strEntry1b, strValue1
  End If
  If strValue1 <> “” Then
  bech=  strValue1 & “,”
  End If
  objReg.GetStringValue HKLM, strKey & strSubkey, _
   strEntry2, strValue2
  If strValue2 <> “” Then

   bech= bech & strValue2 & “,”
  End If
  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
   strEntry3, intValue3
  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
   strEntry4, intValue4
  If intValue3 <> “” Then
     bech= bech &  intValue3 & “.” & intValue4 & “,”
  End If
  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
   strEntry5, intValue5
  If intValue5 <> “” Then
    bech= bech & Round(intValue5/1024, 3)
 objFile.WriteLine bech
  End If
Next
objFile.Close

Uninstall old version of Java and reinstall new

Reading Time: < 1 minute

The below script, uninstalls versions: Java 6 29, Java 6 27, Java 6 26 and Java 7 5

It then installs Java 7 10 (currently the latest version as of 20/12/2012)

Please amend last line as required, amending path to latest version of Java. for latest offline version visit http://java.com/en/download/manual.jsp

Copy the script to notepad and rename to a .bat file, example UpgradeJava.bat

To locate the GUID of java versions (e.g..26A24AE4-039D-4CA4-87B4-2F83216029FF) open command prompt on a machine and type wmic product list and press entrer. Wait for a minute, locate the java versions and GUID and add to the below script if the version is not alreadty there.

Now you can either run this manually or apply via group policy (startup script). Allow 20 mins and reboot machine, may need to reboot a couple of times if replication is still occuring around the network.

JAVAUPDATE=0 on the last line ensures users are not prompted with the upgrade java prompt when a new version is released.

Always test, before rolling out to a live environment.

When a new version is released add the previous version to be uninstalled (locate the

Easy and works great!
@echo off
REM next line uninstalls Java 6u29 X86
msiexec /X{26A24AE4-039D-4CA4-87B4-2F83216029FF} /qn REBOOT=ReallySuppress

REM next line uninstalls Java 6u27 X86
msiexec /X{26A24AE4-039D-4CA4-87B4-2F83216027FF} /qn REBOOT=ReallySuppress

REM next line uninstalls Java 6u26 X86
msiexec /X{26A24AE4-039D-4CA4-87B4-2F83216026FF} /qn REBOOT=ReallySuppress

REM next line uninstalls Java 7u5 X86
msiexec /X{26A24AE4-039D-4CA4-87B4-2F83217005FF} /qn REBOOT=ReallySuppress

REM next line Installs Java 7u10 X86 and creates a LOG file.
\\servername\share\java\JavaVersion710\jre-7u10-windows-i586” /s IEXPLORER=1 MOZILLA=1 /L C:\javaupdate7u10.log REBOOT=ReallySuppress JAVAUPDATE=0

(When copyinh the above script, may need to reenter the speech (“) marks

If you have a mix of 32 and 64 bit machines add 64 bit machines to the script

Download offline version of Java at http://java.com/en/download/manual.jsp

Output server IP details to text file

Reading Time: < 1 minute

The below script will allow you to output ip details for multiple servers on a network.

You will need powershell v2 installed and the PsExec executable

Copy & paste the following into Powershell amending the paths as required.

$inputfile = ‘C:\serverslist.txt’  #this is the file containing the list of server host names, one per line

$outputfolder = ‘C:\outputfolder\’  #this is the folder where the output text files will be stored

set-alias psexec ‘C:\PsExec.exe’ #this is the path to the free Sysinternals PsExec tool, available from http://technet.microsoft.com/en-us/sysinternals/bb897553

$servers=Get-Content $inputfile #get list of server hostnames

$serverscount = $servers.count;$i=0 #set values for progress counter

foreach ($server in $servers) {  #loop systematically through each server in the intput file

$i++  #increment progress counter   

Write-Progress -Activity “Checking servers for IPconfig and static route info” -Status “Querying:” -percentcomplete ((($i-1) / $serverscount)*100) -CurrentOperation “$server ($i of $serverscount)”  #display progress to the end user

$serverUNC = “\\” + $server  #PsExec requires server names to have \\ in front of them

$ipconfigoutput = & PsExec $serverUNC ipconfig /all #Connect to remote server using PsExec and run ipconfig /all

$routeprintoutput = & PsExec $serverUNC route print #Connect to remote server user PsExec and run route print

$outputfilename = $outputfolder+$server+”.txt”  #generate file name based on server name

($ipconfigoutput + $routeprintoutput) | out-file $outputfilename #output data to text file

}

Thanks to Nadeem Ahmed for providing this script