If you are an Exchange Admin, you may have inherited Exchange Servers and are not sure what version you are running or you are simply managing Exchange but need to check Control Panel for installed updates to see what version you are on. If you have a few hundred or thousands of servers, this can become a tedious task.

I put together a PowerShell Script for Exchange Server 2019 (only) that gives you the standard information such as Edition, Version and FileInfo, however you will only see a long number such as “15.02.1258.028” and this would then need to be cross checked with the Exchange Learn site where Microsoft give the information about each version.

To get the Exchange 2016 one, head over to this link on my blog:

The script I have does this for you and gives you the information in a Grid layout and the ProductName field is what you are looking for. Here is a snippet from my one lab:

Exchange 2019:- get the version with product name in powershell
Exchange 2019:- Get the Version with Product Name in PowerShell 1

and from the other lab:

Exchange 2019:- get the version with product name in powershell
Exchange 2019:- Get the Version with Product Name in PowerShell 2

I do not list every Security Update (SU) and Cumulative Update (CU) but only show CU13 and CU12 with all there updates. I will update the script in time with all versions but you can see in the second screenshot that “Exchange Server 2019 Preview” is listed and its version is “15.02.0196.000” as listed on the learn website.

Script

The script is rather long, I ran it from PowerShell ISE, PowerShell and the Exchange Management Shell (EMS) as the script adds the Snapin for Exchange Server 2019. Below is the script, you can add info to the Build Table if you need to but as mentioned will update it.

 # Import the Exchange module
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn


# Define a hashtable with build numbers and corresponding product names
$buildInfoTable = @{

    "15.02.0196.000" = "Exchange Server 2019 Preview";    
    "15.02.1118.007" = "Exchange Server 2019 CU12 (2022H1)";
    "15.02.1118.009" = "Exchange Server 2019 CU12 May22SU";
    "15.02.1118.012" = "Exchange Server 2019 CU12 Aug22SU";
    "15.02.1118.015" = "Exchange Server 2019 CU12 Oct22SU";
    "15.02.1118.020" = "Exchange Server 2019 CU12 Nov22SU";
    "15.02.1118.021" = "Exchange Server 2019 CU12 Jan23SU";
    "15.02.1118.025" = "Exchange Server 2019 CU12 Feb23SU";
    "15.02.1118.026" = "Exchange Server 2019 CU12 Mar23SU";
    "15.02.1118.030" = "Exchange Server 2019 CU12 Jun23SU";
    "15.02.1118.036" = "Exchange Server 2019 CU12 Aug23SU";
    "15.02.1118.037" = "Exchange Server 2019 CU12 Aug23SUv2";
    "15.02.1118.039" = "Exchange Server 2019 CU12 Oct23SU";
    "15.02.1118.040" = "Exchange Server 2019 CU12 Nov23SU";
    "15.02.1258.012" = "Exchange Server 2019 CU13 (2023H1)";
    "15.02.1258.016" = "Exchange Server 2019 CU13 Jun23SU";
    "15.02.1258.023" = "Exchange Server 2019 CU13 Aug23SU";
    "15.02.1258.025" = "Exchange Server 2019 CU13 Aug23SUv2";
    "15.02.1258.027" = "Exchange Server 2019 CU13 Oct23SU";
    "15.02.1258.028" = "Exchange Server 2019 CU13 Nov23SU";
    "15.02.1258.032" = "Exchange Server 2019 CU13 Mar24SU";
    "15.02.1258.034" = "Exchange Server 2019 CU13 Apr24HU";
    "15.02.1544.004" = "Exchange Server 2019 CU14 (2024H1)";
    "15.02.1544.009" = "Exchange Server 2019 CU14 Mar24SU";
    "15.02.1544.011" = "Exchange Server 2019 CU14 Apr24HU";
}

# Function to get product name based on build number
function Get-ProductName($buildNumber) {
    if ($buildInfoTable.ContainsKey($buildNumber)) {
        $buildInfoTable[$buildNumber]
    } else{
        "Unknown Product"
    }
}

$ExchangeServers = Get-ExchangeServer | Sort-Object Name

# Create an array to store the results
$results = @()

foreach ($Server in $ExchangeServers) {
    $serverName = $Server.Name
    $edition = $Server.Edition

    # Get Exchange version using Invoke-Command
    $version = Invoke-Command -ComputerName $Server.Name -ScriptBlock {
        Get-Command Exsetup.exe|ForEach-Object{ $_.FileVersionInfo.FileVersion }
    }

    # Get product name from the local table
    $productName = Get-ProductName $version

    # Create a custom object with the information
    $resultObject = [PSCustomObject]@{
        ServerName   =$serverName
        Edition      =$edition
        Version      =$version
        ProductName  =$productName
    }

    # Add the result object to the results array
    $results += $resultObject
}

# Display the results in a grid
$results | Out-GridView

If you do not want to show the information in a Grid, you can either export it to a CSV file or display on screen.

Hope it helps.

Discover more from COLLABORATION PRO

Subscribe now to keep reading and get access to the full archive.

Continue reading