Link to home
Start Free TrialLog in
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
Avatar of yo_bee
yo_bee
Flag of United States of America image

Your where-object is not needed. You are asking to filter against a wind card. What you are doing is saying where anything = anything.
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?
Avatar of A S
A S

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Michael B. Smith
Michael B. Smith
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial