Public/Assert-PdqMinimumVersion.ps1

<#
.SYNOPSIS
Compares the installed version against a specified version.
 
.DESCRIPTION
Verifies the installed version is equal to or greater than the specified minimum version.
If the installed version is lower than the minimum version, this function will throw an error.
 
.INPUTS
None.
 
.OUTPUTS
None.
 
.EXAMPLE
Assert-PdqMinimumVersion -Product 'Deploy' -MinimumVersion '19.3.36.0'
Verifies that the installed version of PDQ Deploy is at least 19.3.36.0.
#>

function Assert-PdqMinimumVersion {

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [ValidateSet('Deploy', 'Inventory')]
        # The PDQ application you would like to execute this function against.
        [String]$Product,

        [Parameter(Mandatory = $true)]
        # The version number you want to compare against the installed version.
        [Version]$MinimumVersion
    )

    $InstalledVersion = Get-PdqInstalledVersion -Product $Product

    if ( $InstalledVersion -lt $MinimumVersion ) {

        $CallingFunction = (Get-PSCallStack)[1].Command
        throw "The minimum version of PDQ $Product for $CallingFunction is $MinimumVersion. You have $InstalledVersion."

    }

}