
&"$PSScriptRoot\vars.ps1"

if ($PSVersionTable.PSVersion -lt ([Version]$POWERSHELL_VERSION))
{
    try {
        Write-Host "Updating Powershell to version: $POWERSHELL_VERSION"
        Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -useMSI -EnablePSRemoting -Quiet"
    } catch {
        Write-Error "Upgrade PowerShell (Download and run): https://github.com/PowerShell/PowerShell/releases/download/v$POWERSHELL_VERSION/PowerShell-$POWERSHELL_VERSION-win-x64.msi"
        $confirmation = Read-Host "Continue? (y): "
        if (-NOT($confirmation -eq 'y'))
        {
            Write-Error "Stopping" -ErrorAction Stop
        }
    }
}
