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
A SAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yo_beeDirector of Information TechnologyCommented:
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. SmithManaging ConsultantCommented:
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?
A SAuthor Commented:
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
Michael B. SmithManaging ConsultantCommented:
We use 'if' statements.

$WindowsVersion = [environment]::OSVersion.Version.Build
$McAfeeAV = (Get-WmiObject -Class Win32_Product | Where-Object -FilterScript {$_.Name -eq "McAfee Agent"} ) 

if( $WindowsVersion -eq 16299 )
{
    ## OS success
}
if( $McAfeeAV.Version -eq '10.01' )
{
    ## a/v success
}
if ( $WindowsVersion -eq 16299 -AND  $McAfeeAV.Version -eq '10.01' )
{
    ## complete success
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.