GetSystemSoftware.psm1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
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.1 .LINK https://www.mosaicmk.com #> param( [string]$ComputerName = $env:computername, [Parameter(Mandatory=$true)] [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 } } |