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 - Pulls the software info from the computer registry, Requires WinRM to be running on the target computer .NOTES Contact: contact@mosaicmk.com Version: 3.2.2 .LINK https://www.mosaicmk.com #> param( [string]$ComputerName = $env:computername, [ValidateSet('Registry','WMI')] [string]$QueryType ) # IF (($ComputerName -ne $env:computername) -and ($QueryType -eq "Registry")) {Throw "Registy Query Type wil only query the local device"} If (!($QueryType)){$QueryType='WMI'} $ComputerSoftware = @() IF ($QueryType -eq "Registry"){ [array]$uniReg = Invoke-Command -ComputerName $ComputerName {Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" | Get-Item | Get-ItemProperty} foreach ($item in $uniReg){ if ($item.DisplayName){ $Name = $item.DisplayName $Version = $item.DisplayVersion $Publisher = $item.Publisher $InstallSource = $item.InstallSource $InstallDate = $item.InstallDate $UninstallString = $item.UninstallString $ComputerSoftware += [pscustomobject]@{ Name = $Name Version = $Version Publisher = $Publisher InstallDate = $InstallDate InstallSource = $InstallSource UninstallString = $UninstallString } } } [array]$uniReg = Invoke-Command -ComputerName $ComputerName {Get-ChildItem -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | Get-Item | Get-ItemProperty} foreach ($item in $uniReg){ if ($item.DisplayName){ $Name = $item.DisplayName $Version = $item.DisplayVersion $Publisher = $item.Publisher $InstallSource = $item.InstallSource $InstallDate = $item.InstallDate $UninstallString = $item.UninstallString $ComputerSoftware += [pscustomobject]@{ Name = $Name Version = $Version Publisher = $Publisher InstallDate = $InstallDate InstallSource = $InstallSource UninstallString = $UninstallString } } } $ComputerSoftware } IF ($QueryType -eq "WMI"){ $SFInfo = Get-WmiObject Win32_Product -ComputerName $ComputerName foreach ($item in $SFInfo){ $Name = $item.Name $ID = $item.IdentifyingNumber $Publisher = $item.Vendor $Version = $item.Version $InstallDate = $item.InstallDate $InstallSource = $item.InstallSource $UninstallString = $item.UninstallString $ComputerSoftware += [pscustomobject]@{ Name = $Name Version = $Version ID = $ID Publisher = $Publisher InstallDate = $InstallDate InstallSource = $InstallSource UninstallString = $UninstallString } $ComputerSoftware } } } |