If Less Than – Query result of an output

Hello Everyone,

I am 100% new to scripting (this is my first PowerShell attempt). I am trying to check for an installed application version and if it is less than X.X.X.X, I want it to perform function A. If it is equal to or higher than X.X.X.X, I want it to perform function B. I am able to successfully find the software via PowerShell, however, I am not sure how to get my if statement to reference the DisplayVersion field of the results. Can anyone help me out? The below command does return the desired results for me. I think Ideally, I need to declare my displayname as a variable, something like AppName = “My App” and then change the command to reference $AppName instead of the ^*bitdefender*.

if ($CheckAppVersion -lt x.x.x.x) is the part I do not know how to get it to reference the DisplayVersion object results from the command.

$CheckAppVersion = Get-ItemProperty HKLM:SoftwareMicrosoftWindowsCurrentVersionUninstall* | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -match "^*bitdefender*"} if ($CheckAppVersion -lt x.x.x.x) { Write-Host "Upgrade Required" -ForegroundColor Red } else { Write-Host "Correct Version Installed" -ForegroundColor Green } 

Any assistance you can offer is most appreciated. I apologize in advance if I am not coming across clearly.

submitted by /u/justmirsk
[link] [comments]

Leave a Reply