Posted On March 8, 2022

PowerShell: Check Whether an Application Is Installed Using Known Service Name

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Check Whether an Application Is Installed Using Known Service Name
# Check whether product is installed
$serviceName='windows_exporter'
function checkUninstall($serviceName){
    $cpuArchitecture32bitPointerSize=4
    $path=if ([IntPtr]::Size -eq $cpuArchitecture32bitPointerSize) {
        'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
    }else{
        @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
          'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
    }
    Get-ItemProperty $path |.{process{ if ($_.DisplayName -eq $serviceName -and $_.UninstallString) { $_ } }} |
    Select-Object DisplayName, Publisher, InstallDate, DisplayVersion, UninstallString
}
checkUninstall $serviceName

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: How to Send Key Strokes to a Program Graphical User Interface

# WARNING: there's a kill-process command when the target program is already running # so…

Python Module: Datetime

Datetime Programs often include dates and time to perform interactive greetings, calculate age, stamping backups,…

How to Install Secured Shell SSH on Windows

# Windows 10 & Server 2019 # Install the OpenSSH Server Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0…