PoshCode Archive  Artifact [4f5b74368b]

Artifact 4f5b74368bdaf07812582eef0495c40bde53b95c0a4a4709fa477391f45ceeb6:

  • File Local-Software-Inventory.ps1 — part of check-in [906ef2479a] at 2018-06-10 13:17:21 on branch trunk — This script will create (using COM) an MS Excel spreadsheet of all the software installed on the local machine. Basic information about the software, as provided in the registry, is also included. When the script has completed the data collection, all columns are set to “Auto Fit” for width and blank rows in the spreadsheet are removed. (user: AlphaSun size: 2235)

# encoding: ascii
# api: powershell
# title: Local Software Inventory
# description: This script will create (using COM) an MS Excel spreadsheet of all the software installed on the local machine. Basic information about the software, as provided in the registry, is also included. When the script has completed the data collection, all columns are set to “Auto Fit” for width and blank rows in the spreadsheet are removed.
# version: 0.1
# author: AlphaSun
# license: CC0
# x-poshcode-id: 2940
# x-archived: 2015-11-26T04:42:36
# x-published: 2011-08-31T14:50:00
#
#
# Create a new Excel object using COM
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $True
$Excel.DisplayAlerts = $False

# Counter variable for rows
$intRow = 1

$Excel = $Excel.Workbooks.Add()
$Sheet = $Excel.Worksheets.Item(1)

#Create column headers
$Sheet.Cells.Item($intRow,1)  = "Software Vendor"
$Sheet.Cells.Item($intRow,1).Font.Bold = $True
$Sheet.Cells.Item($intRow,2)  = "Software Name"
$Sheet.Cells.Item($intRow,2).Font.Bold = $True
$Sheet.Cells.Item($intRow,3)  = "Version"
$Sheet.Cells.Item($intRow,3).Font.Bold = $True
$Sheet.Cells.Item($intRow,4)  = "Estimated Size (KB)"
$Sheet.Cells.Item($intRow,4).Font.Bold = $True
$Sheet.Cells.Item($intRow,5)  = "Installation Date"
$Sheet.Cells.Item($intRow,5).Font.Bold = $True

$Results = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*

foreach ($objResult in $Results)
{
	$intRow++
	$Name = $objResult.DisplayName
	$SizeKB = $objResult.EstimatedSize
	$Version = $objResult.DisplayVersion
	$InstDate = $objResult.InstallDate
	$Vendor = $objResult.Publisher
	$Sheet.Cells.Item($intRow,1) = $Vendor
	$Sheet.Cells.Item($intRow,2) = $Name
	$Sheet.Cells.Item($intRow,3) = $Version
	$Sheet.Cells.Item($intRow,4) = $SizeKB
	$Sheet.Cells.Item($intRow,5) = $InstDate
}

$Sheet.UsedRange.EntireColumn.AutoFit()

$i = 1

$xlCellTypeLastCell = 11
$used = $Sheet.usedRange
$lastCell = $used.SpecialCells($xlCellTypeLastCell)
$row = $lastCell.row
for ($i = 1; $i -le $row; $i++)
{
	If ($Sheet.Cells.Item($i, 1).Value() -eq $Null)
	{
		$Range = $Sheet.Cells.Item($i, 1).EntireRow
		$Range.Delete()
	}
}