VersionCheck.ps1


Function VersionCheck([string]$Deployment, [string]$CustomerId)
{
    $moduleName = 'Citrix.Workloads.Portability'
    $moduleInfo = Get-InstalledModule $moduleName

    try {
        $response = Invoke-CCRestMethod -method 'Get' -deployment $Deployment -serviceRoute "info/powershellModuleVersions" -customerId $CustomerId -authenticated $false
        LogIt "Latest versions $response" $false
        $latestVersion = [System.Version]$response.$moduleName
        $moduleVersion = [System.Version]$moduleInfo.Version
        if ($moduleVersion -lt $latestVersion)
        {
            LogItWarning "Update available: The latest version of $moduleName is $latestVersion and you have $moduleVersion. Please update to the latest and restart your shell."
        }
    } catch {
        LogIt "Failed to get latest version: $_"
    }
}