Menu Close

How to check for latest Azure AD Connect version available online using PowerShell

Since my first post was about how to download and get the “FriendlyNames” of the licenses in your Azure AD environment, using Invoke-Webrequest, I figured another good tip could be how you can check for the latest version of AzureAD Connect online using PowerShell.

This is also done with Invoke-WebRequest, and I know there are different methods to do this, but on the server I am using I am doing it this way (because first run configuration of IE is not peformed)

Once you get the version available online, you can in turn compare the value here with your existing servers and version numbers to see which server needs an upgrade or not 😉

# Find version number
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    
$TempAzure = Invoke-WebRequest -Uri https://docs.microsoft.com/en-us/azure/active-directory/hybrid/reference-connect-version-history -UseBasicParsing
    $TempAzure.content | Out-File $env:TEMP\AzureVersion.TXT
    $AzureFile = Get-Content $env:TEMP\AzureVersion.TXT | Select-String -Pattern "<h2 id="
    $Azure = $AzureFile -replace  "\<.*?\>"
     
    $versionList = @()
    # Because we get different values returned, we check if the value can be defined as a version object.
    Foreach ($value in $Azure ) {
        write-Output "Checking value: $value"
        try {
            $versionlist += [version]$value
        }
        catch {
            Write-output "Not a version value"
        }
        
    }
    # Find the highest version available 
    $latestVersionOnline = ($versionList | measure-object -Maximum).Maximum
    $latestVersionOnline

When the code is run, we get an output similar to this(These are the values we have in our $Azure variable):

And when we check for the highest number we get the latest version online 🙂

1 Comment

Comments are closed.