Function Get-Installed Application

Topics: Archive - General
Jun 1, 2014 at 5:41 PM
Hello,
I want to use the Get-InstalledApplication function. After some tests, the function works but I don'tt know how to retrieve the result in another variable powershell. Could you help me?

Example Script :
Get-InstalledApplication -Name "HP Documentation"

Result in the console PS1 :

Getting information for installed Application Name [HP Documentation]...
[01-06-2014 18:35:24] [Installation] Found installed application [HP Documentation] version [1.1.0.0] matching application name [HP Documentation]


InstallSource : C:\SwSetup\HPD1053\
UninstallString : MsiExec.exe /X{53CD60C7-12F9-420D-A9BF-EC8D815475A9}
ProductCode : {53CD60C7-12F9-420D-A9BF-EC8D815475A9}
InstallLocation : C:\Program Files (x86)\Hewlett-Packard\Documentation\
Publisher : Hewlett-Packard
InstallDate : 20110104
DisplayVersion : 1.1.0.0
DisplayName : HP Documentation

Question:
Can I retrieve commits UninstallString variable and its value ?

Thank you in advance for your help !
Congratulations for this development !
Coordinator
Jun 2, 2014 at 12:16 AM
Hi,

Try this:

$uninstallStringValue = Get-InstalledApplication "HP Documentation" | select "uninstallstring" -expand "uninstallstring"

Sean
Jun 2, 2014 at 7:55 AM
Hi Sean,

It works !
Thank you very much because I'm a beginner in powershell and I could not find the solution !
Thank you !!!

Best Regards
Fabrice


Mar 19, 2015 at 6:50 PM
working on something similar and need to perform a install based on the results.

here is what is not working for me..

$IsAppInst = Get-InstalledApplication -name 'paint.net'| Select "DisplayVersion" -ExpandProperty "DisplayVersion"
If($IsAppInst -eq "4.0.5"){prompt users}
else{perform install step}

when I run the script I get.. (Testing with version 3.5.0 PSAPPDT)

[dotPDNLLC_paint.net_4.0.5] setup started.
[03-19-2015 12:43:20.411] [Initialization] [PSAppDeployToolkitExt] :: Script [C:\WINDOWS\Brunswick\AppDeployToolkit\AppDeployToolkitExtensions.ps1] dot-source invoked by [C:\WINDOWS\Brunswick\AppDeployToolkit\AppDeployToolkitMa
in.ps1]
[03-19-2015 12:43:20.415] [Initialization] :: You cannot call a method on a null-valued expression. (at <ScriptBlock>, C:\WINDOWS\Brunswick\AppDeployToolkit\AppDeployToolkitMain.ps1: line 7731
at <ScriptBlock>, C:\WINDOWS\Brunswick\AppDeployToolkit\AppDeployToolkitMain.ps1: line 7731
at <ScriptBlock>, C:\Windows\ccmcache\e\Deploy-paint.net.ps1: line 77)
[03-19-2015 12:43:20.420] [Initialization] [Show-DialogBox] :: Display Dialog Box with message: You cannot call a method on a null-valued expression. (at <ScriptBlock>, C:\WINDOWS\Brunswick\AppDeployToolkit\AppDeployToolkitMain
.ps1: line 7731
at <ScriptBlock>, C:\WINDOWS\Brunswick\AppDeployToolkit\AppDeployToolkitMain.ps1: line 7731
at <ScriptBlock>, C:\Windows\ccmcache\e\Deploy-paint.net.ps1: line 77)...
[03-19-2015 12:43:24.942] [Initialization] [Show-DialogBox] :: Dialog Box Response: OK

if I simply highlight and run the code I get this:
PS C:\WINDOWS\system32> $IsAppInst = Get-InstalledApplication -name 'paint.net'| Select "DisplayVersion" -ExpandProperty "DisplayVersion"
$IsAppInst
[03-19-2015 12:46:30.828] [Initialization] [Get-InstalledApplication] :: Get information for installed Application Name(s) [paint.net]...
[03-19-2015 12:46:30.915] [Initialization] [Get-InstalledApplication] :: Found installed application [paint.net] version [4.0.5] matching application name [paint.net]
4.0.5

thanks in advance
Mar 19, 2015 at 7:26 PM
ok so I think I got it working. Strange thing is that when I run it via ise it fails. If I select the section of code I want and run it only it works and it works fine when initiated via cm12 software center. Here is the updated code I tried for this.

check to see if its installed already

If((Get-InstalledApplication 'paint.net' | Select "DisplayVersion" -ExpandProperty "DisplayVersion")-eq "4.0.5"){
$MsgText = "I have detected that you already have $InstallTitle

Nothing more to do, exiting the install."

$UserPrompt = Show-InstallationPrompt -message "$MsgText" -ButtonRightText "OK" -Icon "Information" -MinimizeWindows $True -timeout 900
Exit-Script -ExitCode 0
}
Else{
# Install it
Show-InstallationProgress -StatusMessage "Installing $InstallTitle    

Please wait..."
If ($is64bit -eq $true){Execute-MSI -Action Install -Path $DirFiles\PaintDotNet_x64.msi -Parameters " /quiet /norestart"}
Else{Execute-MSI -Action Install -Path $DirFiles\PaintDotNet_x86.msi -Parameters " /quiet /norestart"}
}