Avatar of A S
A S asked on

Batch file or powershell to check the version of installed program and OS

hello Experts,

I am in process of creating a Script that check for operating system version and software installed version.  if the operating system build number equals 16299 and installed software version 2.8 dont do nothing if not throw a message, to update for software.
Is that possible
Get-WmiObject -Class Win32_Product | Select-Object Name, Version | Where-Object -FilterScript {$_.Name -like "*"} 

Open in new window

[environment]::OSVersion.Version

Open in new window


i got these but, dont know where to go.

Thanks
PowershellSoftwareGolang

Avatar of undefined
Last Comment
Michael B. Smith

8/22/2022 - Mon
yo_bee

Your where-object is not needed. You are asking to filter against a wind card. What you are doing is saying where anything = anything.
Michael B. Smith

The OS part is easy

if( [environment]::OSVersion.Version.Build -eq 16299 )
{
    # check the app version
}

Open in new window

What is the name of the app?
ASKER
A S

Thanks Micheal,
I came up with below
$WindowsVersion = [environment]::OSVersion.Version.Build

if( $WindowsVersion -match "16299" ) {
Write-Output "success"
}
else
{
Write-Output "fail"
}
if (Get-WmiObject -Class Win32_Product | Where-Object -FilterScript {$_.Name -eq "McAfee Agent"} |  Where-Object -FilterScript {$_.version -eq "10.01"} | Format-List -Property Name,Version) {
Write-Output "success"
}
else
{
Write-Output "fail"
}

Open in new window

Is there any option in powershell like GOTO. if version matches check for product both success dont do nothing, if any of that fails shutdown computer
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Michael B. Smith

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question