2021-07-23 17:47:26 -04:00
|
|
|
## Specify output file to write data to
|
|
|
|
|
$FILE = "${Env:UserProfile}\Desktop\InstalledSoftware.csv"
|
|
|
|
|
|
|
|
|
|
## Clear content of output file
|
|
|
|
|
If ( Test-Path $FILE ) { Clear-Content -Path $FILE -Force }
|
|
|
|
|
|
|
|
|
|
## Write the headers to the output file
|
|
|
|
|
Write-LineToFile -Path $FILE -Line "Name,Publisher,Version,InstallDate,EstimatedSize(MB),UninstallString,ModifyPath"
|
2021-07-23 17:04:25 -04:00
|
|
|
|
|
|
|
|
ForEach ( $item in $(Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall','HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') ) {
|
|
|
|
|
If ( Test-ItemProperty -Path $item.PSPath -Name DisplayName ) {
|
|
|
|
|
$DisplayName = Get-ItemPropertyValue -Path $item.PSPath -Name DisplayName
|
2021-07-23 17:47:26 -04:00
|
|
|
$DisplayName = $DisplayName -replace ",", " "
|
2021-07-23 17:04:25 -04:00
|
|
|
} Else { $DisplayName = "" }
|
|
|
|
|
|
|
|
|
|
If ( Test-ItemProperty -Path $item.PSPath -Name DisplayVersion ) {
|
|
|
|
|
$DisplayVersion = Get-ItemPropertyValue -Path $item.PSPath -Name DisplayVersion
|
2021-07-23 17:47:26 -04:00
|
|
|
$DisplayVersion = $DisplayVersion -replace ",", " "
|
2021-07-23 17:04:25 -04:00
|
|
|
} Else { $DisplayVersion = "" }
|
|
|
|
|
|
|
|
|
|
If ( Test-ItemProperty -Path $item.PSPath -Name EstimatedSize ) {
|
|
|
|
|
$EstimatedSize = Get-ItemPropertyValue -Path $item.PSPath -Name EstimatedSize
|
2021-07-23 17:47:26 -04:00
|
|
|
$EstimatedSize = $EstimatedSize -replace ",", " "
|
|
|
|
|
$size = [int]$EstimatedSize
|
|
|
|
|
$size = [Math]::Ceiling($size / 1024)
|
|
|
|
|
$EstimatedSize = [string]$size
|
2021-07-23 17:04:25 -04:00
|
|
|
} Else { $EstimatedSize = "" }
|
|
|
|
|
|
|
|
|
|
If ( Test-ItemProperty -Path $item.PSPath -Name InstallDate ) {
|
|
|
|
|
$InstallDate = Get-ItemPropertyValue -Path $item.PSPath -Name InstallDate
|
2021-07-23 17:47:26 -04:00
|
|
|
$InstallDate = $InstallDate -replace ",", " "
|
2021-07-23 17:04:25 -04:00
|
|
|
} Else { $InstallDate = "" }
|
|
|
|
|
|
|
|
|
|
If ( Test-ItemProperty -Path $item.PSPath -Name Publisher ) {
|
|
|
|
|
$Publisher = Get-ItemPropertyValue -Path $item.PSPath -Name Publisher
|
2021-07-23 17:47:26 -04:00
|
|
|
$Publisher = $Publisher -replace ",", " "
|
2021-07-23 17:04:25 -04:00
|
|
|
} Else { $Publisher = "" }
|
|
|
|
|
|
|
|
|
|
If ( Test-ItemProperty -Path $item.PSPath -Name UninstallString ) {
|
|
|
|
|
$UninstallString = Get-ItemPropertyValue -Path $item.PSPath -Name UninstallString
|
2021-07-23 17:47:26 -04:00
|
|
|
$UninstallString = $UninstallString -replace ",", " "
|
2021-07-23 17:04:25 -04:00
|
|
|
} Else { $UninstallString = "" }
|
|
|
|
|
|
|
|
|
|
If ( Test-ItemProperty -Path $item.PSPath -Name ModifyPath ) {
|
|
|
|
|
$ModifyPath = Get-ItemPropertyValue -Path $item.PSPath -Name ModifyPath
|
2021-07-23 17:47:26 -04:00
|
|
|
$ModifyPath = $ModifyPath -replace ",", " "
|
2021-07-23 17:04:25 -04:00
|
|
|
} Else { $ModifyPath = "" }
|
|
|
|
|
|
2021-07-23 17:47:26 -04:00
|
|
|
## Write installed software to output file only if it has a name, otherwise discard
|
|
|
|
|
If ( $DisplayName -ne "" ) {
|
|
|
|
|
$content = "${DisplayName},${Publisher},${DisplayVersion},${InstallDate},${EstimatedSize},${UninstallString},${ModifyPath}"
|
|
|
|
|
Write-LineToFile -Path $FILE -Line $content
|
|
|
|
|
}
|
2021-07-23 17:04:25 -04:00
|
|
|
}
|