I think you're using the the Get-InstalledApplication function incorrectly. When you make a call to this function, it returns the following properties for every application that it found: ProductCode, DisplayName, DisplayVersion, UninstallString, InstallSource, InstallLocation, InstallDate, Publisher, Is64BitApplication.
DisplayVersion is the property with the version number of the application that it found. So to use it properly in your code to do the detection, you would use it like thus:
DisplayVersion is the property with the version number of the application that it found. So to use it properly in your code to do the detection, you would use it like thus:
$VLCInstall = Get-InstalledApplication -Name "VLC media player"
If ($VLCInstall -and (VLCInstall.DisplayVersion -eq '2.2.0')) {
# Contdition met, exit
}
Else {
# Condition not met, proceed with install
}
You can search in the toolkit to see where we are removing white spaces from the $appName variable. It is done to avoid various issues in the script when we use it to build other variables and file names. I would suggest not using this variable to control your logic or how you log if you don't want the white space to be stripped.