Q:

Check if program with specific version is installed

I'm trying to create a very simple script which would check if the a specific program is installed and if so return the version number for that program. 
I've been able to get to the point where I'm running the script and able to return a binary value if a program is installed or not but not sure how to return the version number for that installed program.
What I will post will be just what I'm doing to return if program is installed, and need help in then attaining the version number.
function Check_Program_Installed {
    $my_check = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
                Select-Object DisplayName, DisplayVersion, InstallDate |
                Format-Table -AutoSize |
                Out-String

    # Check if Google Chrome is installed
    $my_check -Match "Google Chrome"
}

Check_Program_Installed

A:

Instead of doing the match after formatting the table, you could add a where to select the result you need beforehand and then obtain the DisplayVersion directly from that object.  You could clean this up more to do exactly what you need, but here is your code modified to retrieve and display the number if the application is found.  Try switching to a bad name to see the else result:
function Get-ApplicationVersion {

    $applicationName = "Google Chrome"

    $my_check = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, InstallDate | Where -Property DisplayName -Match $applicationName

    $versionNumber = $my_check.DisplayVersion

    if ($my_check) {
        $versionNumber
    }
    else {
        write-warning "Application not found"
    }

}

Get-ApplicationVersion

EDITED: Renamed function name from Check_Program_Installed to use PS common verb Get, per suggestion.

A:

function Get-InstalledProgram {
    Param (
        $ProgramName
    )

    $UninstallKeys = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* 

    if ( $ProgramName )
    {
        $UninstallKeys | Where-Object -Property DisplayName -Match -Value $ProgramName | Select-Object DisplayName, DisplayVersion, InstallDate
    }
    else
    {
        $UninstallKeys | Select-Object DisplayName, DisplayVersion, InstallDate
    }
}

If you wanted to see all the programs, then you don't have to add a parameter. Just pipe its output to Format-Table. Format-Table does some weird just where the items are no longer the objects you're expecting, but table objects. Here is how I would handle that:
Get-InstalledProgram | Format-Table -Autosize

If you want to search for a program, add a parameter. You'll see above I added a parameter for ProgramName. It will match this term to the registry key's DisplayName.
PS C:\> Get-InstalledProgram -ProgramName Java

DisplayName       DisplayVersion InstallDate
-----------       -------------- -----------
Java 8 Update 181 8.0.1810.25    20180725   
Java Auto Updater 2.8.181.13     20180925  

If you wanted to just get the version, I would recommend just piping your output to Select-Object -ExpandProperty DisplayVersion
PS C:\> Get-InstalledProgram -ProgramName 'Java 8' | Select-Object -ExpandProperty DisplayVersion
8.0.1810.25

A:

If you want that function to look for a specific installed program instead of returning a (table) formatted string, then you could simply do:
function Check_Program_Installed {
    [CmdletBinding()]
    Param(
        [Parameter(Position = 0, Mandatory=$true, ValueFromPipeline = $true)]
        $Name
    )
    $app = Get-ItemProperty -Path "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | 
                Where-Object { $_.DisplayName -match $Name } | 
                Select-Object DisplayName, DisplayVersion, InstallDate, Version
    if ($app) {
        return $app.DisplayVersion
    }
}

Check_Program_Installed "Google Chrome"

This will return $null when not found, or the version as string like 70.0.3538.67

