GetSystemSoftware.psm1
Function Get-SystemSoftware{ <# .SYNOPSIS Gather software installed on a local or remote device .DESCRIPTION The script will display Software ID number, Name, Publisher and Version. .PARAMETER Computer With this parameter you cam run this on a remote computer .PARAMETER QueryType Specify how you want to gather the information WMI - gather installed software on a remote device but the list may be missing some hidden software Registry - Will not work on a remote device but shows a more indepth list .NOTES Contact: contact@mosaicmk.com Version: 3.1.0 .LINK https://www.mosaicmk.com #> param( [string]$ComputerName = $env:computername, [ValidateSet('Registry','WMI')] [string]$QueryType ) IF (($ComputerName -ne $env:computername) -and ($QueryType -eq "Registry")) {Write-Error "Registy Query Type wil only query the local device";return} IF ($QueryType -eq "Registry"){ $ComputerSoftware = @() $uniReg = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" Set-Location HKLM: | Out-Null foreach ($item in $uniReg){ $I = Get-ItemProperty $item if ($I.DisplayName){ $Name = $I.DisplayName $Version = $I.DisplayVersion $Publisher = $I.Publisher $UninstallString = $I.UninstallString $ComputerSoftware += [pscustomobject]@{ Name = $Name Version = $Version Publisher = $Publisher UninstallString = $UninstallString } } } $uniReg = Get-ChildItem -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" foreach ($item in $uniReg){ $I = Get-ItemProperty $item if ($I.DisplayName){ $Name = $I.DisplayName $Version = $I.DisplayVersion $Publisher = $I.Publisher $UninstallString = $I.UninstallString $ComputerSoftware += [pscustomobject]@{ Name = $Name Version = $Version Publisher = $Publisher UninstallString = $UninstallString } } } Set-Location $PSScriptRoot $ComputerSoftware } IF ($QueryType -eq "WMI"){ $SFInfo = Get-WmiObject Win32_Product -ComputerName $ComputerName $AllObjects = @() foreach ($item in $SFInfo){ $Name = $item.Name $ID = $item.IdentifyingNumber $Vendor = $item.Vendor $Version = $item.Version $AllObjects += [pscustomobject]@{ Name = $name ID = $ID Publisher = $Vendor Version = $Version } } $AllObjects } } |