Function to check if application is already installed

Hi

I am running the script as wrapper for gpo logonscripts
So far so good. I really like the baloontip notifications etc.

But I maybe looking wrong please shed some light

I am looking for a clever way to check if product is already installed (as the script starts again and again at logon)
Do I have to query the productid via registry or file/folder existence or is that already in there with the variables for software version?

I don’t use sccm and I guess normally it’s handled there

Thanks pe

You can use something like:

If (Get-InstalledApplication -Name "application name") { }

or if you want something more global

If ((Get-RegistryKey -Key "HKEY_CURRENT_USER\SOFTWARE<company>$appName\ScriptVersion" -Value $appScriptVersion) -eq $appScriptVersion) { Exit-Script 0 }

<code>#Tracking information that the script was executed
Set-RegistryKey -Key &quot;HKEY_CURRENT_USER\SOFTWARE\&lt;company&gt;&quot;
Set-RegistryKey -Key &quot;HKEY_CURRENT_USER\SOFTWARE\&lt;company&gt;\$appName&quot;
Set-RegistryKey -Key &quot;HKEY_CURRENT_USER\SOFTWARE\&lt;company&gt;\$appName&quot; -Name &quot;ScriptVersion&quot; -Value $appScriptVersion
Set-RegistryKey -Key &quot;HKEY_CURRENT_USER\SOFTWARE\&lt;company&gt;\$appName&quot; -Name &quot;AppVersion&quot; -Value $appVersion</code>

if($env:PROCESSOR_ARCHITECTURE -eq “AMD64”){$HKLMPath = “HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall”}else{$HKLMPath = “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”}

$AdobeRdr= Get-ItemProperty “$HKLMPath*” | Where-Object DisplayName -Like ‘Adobe Reader XI

if($AdobRdr.DisplayVersion -eq “11.0.15”){

Application i Installed. Do nothing (or send status somewhere etc.)

}
else
{

Add your way of deploying the application. I.e.:

“Deploy-Application.exe”
}

That’s an example of how you could deploy Adobe Reader version 11.0.15. Wrap it up in a startupscript.ps1 and try it out :)…

Also, make sure you replace all the bad characters this site is modifying (such as "). Basically set your script up in Powershell ISE and correct spelling.

Whatever you do - do not use the WMI class Win32_Product :)…
ref: https://sdmsoftware.com/group-policy-blog/wmi/why-win32_product-is-bad-news/

Also - misspelled AdobeRdr in the if statement ;)…