ht (c) Microsoft Corporation. All rights reserved.
#
# Script Type: PowerShell
# Script Action: Detection
# Script Version: 2

# Detection script that checks to see if UEV is installed by looking for existence 
# of the UE-V version number in the registry. Application is considered to be 
# installed if this subroutine sends a "Installed" message to std out.
#
# Registry key: HKLM\\SOFTWARE\Microsoft\UEV\Agent\Version

function GetUevVersion
{
    try
    {
        $key = Get-Item -LiteralPath "HKLM:\SOFTWARE\Microsoft\UEV\Agent" -ErrorAction SilentlyContinue
        $version = $key.GetValue("Version", "0");

        if ($version.ToString().Length -ge 2)
        {
            $parts = $version.ToString().Split(".")
            $ver = $parts[0] + "." + $parts[1]
            return [float]$ver
        }
        return 2.0
    }
    catch
    {
        return 2.0
    }
}

$uevVersion = GetUevVersion
if ($uevVersion -ge 2.0)
{ 
    write-host 'Installed' 
}
