Automatizzazione dei prerequisiti di Exchange Server


Automatizzazione completa dei prerequisiti di Exchange Server con uno script PowerShell

Se hai intenzione di installare Microsoft Exchange Server 2019 e versioni successive, stai pensando di automatizzare i prerequisiti di Exchange Server per distribuirlo rapidamente. Ti abbiamo coperto.

L'installazione manuale di Microsoft Exchange Server richiede molto tempo perché è necessario scaricare diversi pacchetti software da fonti diverse.

Dopo averli scaricati e installati, è necessario installare le funzionalità Windows richieste, quindi estendere lo schema, preparare AD e tutti i domini.

Questa operazione manualmente richiede tempo e, se perdi qualcosa, l'installazione di Exchange non continuerà e richiederà di installare la funzionalità mancante.

In questa guida ti guiderò attraverso uno script PowerShell completamente automatizzato che configuratutti i componenti necessariper Exchange Server 2019.

Ad esempio funzionalità Windows, .NET Framework, ridistribuibili C++, UCMA e riscrittura URL.

Questa operazione verrà eseguita con l'aiuto dello script dei prerequisiti di Exchange Server 2019, che è una build completamente automatizzata in PowerShell.

Questo script di Exchange PowerShell è rapido, semplice e sicuro, quindi privo di errori, per automatizzare i prerequisiti di Exchange Server per distribuire rapidamente Exchange Server.

Cosa fa lo script automaticamente

Di solito, sai che esistono più software e funzionalità che devono essere installati prima di installare il server Exchange.

Questo script si occuperà automaticamente dell'installazione dei seguenti software e funzionalità.

  • Installa .NET Framework 4.8
  • Installa i ridistribuibili di Visual C++ (2012 e 2013)
  • Installa i ruoli e le funzionalità di Windows Server richiesti
  • Installa il modulo Riscrittura URL
  • Installa UCMA 4.0
  • Ti assicura di essere pronto per la preparazione dello schema/dominio di Exchange

Pertanto, controlla anche se alcune funzionalità o software sono già installati.

Tuttavia, se trova il software e la funzionalità già installati, salterà il passaggio e procederà oltre.

Prepara automaticamente anche il tuo controller di dominio

Come sai, dobbiamo installare anche .NET Framework, C++ Redistributables sul controller di dominio, insieme ad alcune altre funzionalità di Windows.

Per automatizzarlo, è possibile eseguire lo script seguente prima di eseguire lo script Prerequisiti di automazione di Exchange Server.

# Active Directory Prerequisites Full Installer
# By Techi Jack

Write-Host "Starting Microsoft Exchange AD Prerequisite Installer..." -ForegroundColor Cyan

# Function to check if a redistributable is installed
function Is-VCRedistInstalled {
    param ([string]$DisplayName)
    $keys = @(
        "HKLM:SOFTWAREMicrosoftWindowsCurrentVersionUninstall*",
        "HKLM:SOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionUninstall*"
    )
    foreach ($key in $keys) {
        if (Get-ItemProperty $key -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like "*$DisplayName*" }) {
            return $true
        }
    }
    return $false
}

# Function to check .NET Framework 4.8 or later
function Is-DotNetFramework48Installed {
    $releaseKey = Get-ItemProperty -Path "HKLM:SOFTWAREMicrosoftNET Framework SetupNDPv4Full" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Release
    return ($releaseKey -ge 528040)
}

# Install .NET Framework 4.8 if not installed
if (-not (Is-DotNetFramework48Installed)) {
    Write-Host "Installing .NET Framework 4.8..." -ForegroundColor Cyan
    $dotNetUrl = "https://download.microsoft.com/download/2/4/8/24892799-1635-47E3-AAD7-9842E59990C3/ndp48-web.exe"
    $dotNetPath = "$env:TEMPndp48-web.exe"
    Invoke-WebRequest -Uri $dotNetUrl -OutFile $dotNetPath
    Start-Process -FilePath $dotNetPath -ArgumentList "/quiet /norestart" -Wait
} else {
    Write-Host ".NET Framework 4.8 or newer already installed, skipping..." -ForegroundColor Green
}

# C++ 2012 (x64)
if (-not (Is-VCRedistInstalled -DisplayName "Visual C++ 2012 x64")) {
    Write-Host "Installing Visual C++ 2012 x64..." -ForegroundColor Cyan
    $vc2012Url = "https://download.microsoft.com/download/1/6/b/16b06f60-3b20-4ff2-b699-5e9b7962f9ae/VSU_4/vcredist_x64.exe"
    $vc2012Path = "$env:TEMPvcredist2012_x64.exe"
    Invoke-WebRequest -Uri $vc2012Url -OutFile $vc2012Path
    Start-Process -FilePath $vc2012Path -ArgumentList "/install /quiet /norestart" -Wait
} else {
    Write-Host "Visual C++ 2012 x64 already installed, skipping..." -ForegroundColor Green
}

# C++ 2013 (x64)
if (-not (Is-VCRedistInstalled -DisplayName "Visual C++ 2013 x64")) {
    Write-Host "Installing Visual C++ 2013 x64..." -ForegroundColor Cyan
    $vc2013Url = "https://download.visualstudio.microsoft.com/download/pr/10912041/cee5d6bca2ddbcd039da727bf4acb48a/vcredist_x64.exe"
    $vc2013Path = "$env:TEMPvcredist2013x64.exe"
    Invoke-WebRequest -Uri $vc2013Url -OutFile $vc2013Path
    Start-Process -FilePath $vc2013Path -ArgumentList "/install /quiet /norestart" -Wait
} else {
    Write-Host "Visual C++ 2013 x64 already installed, skipping..." -ForegroundColor Green
}

# Define required features
$features = @(
    "RSAT-ADDS"
)

Write-Host "Checking and installing Windows prerequisites..." -ForegroundColor Cyan

foreach ($feature in $features) {
    $status = Get-WindowsFeature -Name $feature
    if ($status.Installed) {
        Write-Host "$feature is already installed. Skipping..." -ForegroundColor Yellow
    } else {
        Write-Host "Installing $feature..." -ForegroundColor Green
        Install-WindowsFeature -Name $feature -IncludeAllSubFeature -Verbose
    }
}

Write-Host "All AD prerequisites handled successfully." -ForegroundColor Magenta

Come utilizzare lo script di automazione dei prerequisiti di Exchange

Puoi copiare lo script dallo snippet seguente e salvarlo con qualsiasi nome con estensione .ps1.

Nel nostro caso, l'abbiamo salvato nella cartella script sull'unità C.

# Exchange Server 2019 Prerequisites Full Installer
# By Techi Jack

Write-Host "Starting Microsoft Exchange Prerequisite Installer..." -ForegroundColor Cyan

# Function to check if a redistributable is installed
function Is-VCRedistInstalled {
    param ([string]$DisplayName)
    $keys = @(
        "HKLM:SOFTWAREMicrosoftWindowsCurrentVersionUninstall*",
        "HKLM:SOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionUninstall*"
    )
    foreach ($key in $keys) {
        if (Get-ItemProperty $key -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like "*$DisplayName*" }) {
            return $true
        }
    }
    return $false
}

# Function to check .NET Framework 4.8 or later
function Is-DotNetFramework48Installed {
    $releaseKey = Get-ItemProperty -Path "HKLM:SOFTWAREMicrosoftNET Framework SetupNDPv4Full" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Release
    return ($releaseKey -ge 528040)
}

# Install .NET Framework 4.8 if not installed
if (-not (Is-DotNetFramework48Installed)) {
    Write-Host "Installing .NET Framework 4.8..." -ForegroundColor Cyan
    $dotNetUrl = "https://download.microsoft.com/download/2/4/8/24892799-1635-47E3-AAD7-9842E59990C3/ndp48-web.exe"
    $dotNetPath = "$env:TEMPndp48-web.exe"
    Invoke-WebRequest -Uri $dotNetUrl -OutFile $dotNetPath
    Start-Process -FilePath $dotNetPath -ArgumentList "/quiet /norestart" -Wait
} else {
    Write-Host ".NET Framework 4.8 or newer already installed, skipping..." -ForegroundColor Green
}

# C++ 2012 (x64)
if (-not (Is-VCRedistInstalled -DisplayName "Visual C++ 2012 x64")) {
    Write-Host "Installing Visual C++ 2012 x64..." -ForegroundColor Cyan
    $vc2012Url = "https://download.microsoft.com/download/1/6/b/16b06f60-3b20-4ff2-b699-5e9b7962f9ae/VSU_4/vcredist_x64.exe"
    $vc2012Path = "$env:TEMPvcredist2012_x64.exe"
    Invoke-WebRequest -Uri $vc2012Url -OutFile $vc2012Path
    Start-Process -FilePath $vc2012Path -ArgumentList "/install /quiet /norestart" -Wait
} else {
    Write-Host "Visual C++ 2012 x64 already installed, skipping..." -ForegroundColor Green
}

# C++ 2013 (x64)
if (-not (Is-VCRedistInstalled -DisplayName "Visual C++ 2013 x64")) {
    Write-Host "Installing Visual C++ 2013 x64..." -ForegroundColor Cyan
    $vc2013Url = "https://download.visualstudio.microsoft.com/download/pr/10912041/cee5d6bca2ddbcd039da727bf4acb48a/vcredist_x64.exe"
    $vc2013Path = "$env:TEMPvcredist2013x64.exe"
    Invoke-WebRequest -Uri $vc2013Url -OutFile $vc2013Path
    Start-Process -FilePath $vc2013Path -ArgumentList "/install /quiet /norestart" -Wait
} else {
    Write-Host "Visual C++ 2013 x64 already installed, skipping..." -ForegroundColor Green
}

# Define required features
$features = @(
    "Server-Media-Foundation", "NET-Framework-45-Features", "RPC-over-HTTP-proxy", "RSAT-Clustering",
    "RSAT-Clustering-CmdInterface", "RSAT-Clustering-Mgmt", "RSAT-Clustering-PowerShell", "WAS-Process-Model", 
    "Web-Asp-Net45", "Web-Basic-Auth", "Web-Client-Auth", "Web-Digest-Auth", "Web-Dir-Browsing", "Web-Dyn-Compression",
    "Web-Http-Errors", "Web-Http-Logging", "Web-Http-Redirect", "Web-Http-Tracing", "Web-ISAPI-Ext", "Web-ISAPI-Filter",
    "Web-Lgcy-Mgmt-Console", "Web-Metabase", "Web-Mgmt-Console", "Web-Mgmt-Service", "Web-Net-Ext45", "Web-Request-Monitor",
    "Web-Server", "Web-Stat-Compression", "Web-Static-Content", "Web-Windows-Auth", "Web-WMI", "Windows-Identity-Foundation",
    "RSAT-ADDS", "NET-WCF-HTTP-Activation45", "NET-WCF-Pipe-Activation45"
)

Write-Host "Checking and installing Windows prerequisites..." -ForegroundColor Cyan

foreach ($feature in $features) {
    $status = Get-WindowsFeature -Name $feature
    if ($status.Installed) {
        Write-Host "$feature is already installed. Skipping..." -ForegroundColor Yellow
    } else {
        Write-Host "Installing $feature..." -ForegroundColor Green
        Install-WindowsFeature -Name $feature -IncludeAllSubFeature -Verbose
    }
}

# URL Rewrite
$rewriteDll = "$env:SystemRootSystem32inetsrvrewrite.dll"
if (-not (Test-Path $rewriteDll)) {
    Write-Host "Installing IIS URL Rewrite Module 2.1..." -ForegroundColor Yellow
    $urlRewriteUrl = "https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi"
    $urlRewritePath = "$env:TEMPrewrite_2.1_x64.msi"
    Invoke-WebRequest -Uri $urlRewriteUrl -OutFile $urlRewritePath
    Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$urlRewritePath`" /quiet /norestart" -Wait
    Write-Host "URL Rewrite Module installed." -ForegroundColor Cyan
} else {
    Write-Host "URL Rewrite already installed, skipping..." -ForegroundColor Green
}

function Is-UCMAInstalled {
    $ucmaPath = "C:Program FilesMicrosoft UCMA 4.0"
    return (Test-Path $ucmaPath)
}

$UcmaDownloadUrl = "https://download.microsoft.com/download/2/c/4/2c47a5c1-a1f3-4843-b9fe-84c0032c61ec/UcmaRuntimeSetup.exe"
$UcmaInstaller = "$env:TEMPUcmaRuntimeSetup.exe"

if (-not (Is-UCMAInstalled)) {
    Write-Host "UCMA 4.0 not detected." -ForegroundColor Cyan

    if (-not (Test-Path $UcmaInstaller)) {
        Write-Host "Downloading UCMA installer..." -ForegroundColor Cyan
        Invoke-WebRequest -Uri $UcmaDownloadUrl -OutFile $UcmaInstaller -UseBasicParsing
    } else {
        Write-Host "UCMA installer already exists. Skipping download." -ForegroundColor Yellow
    }

    Write-Host "Installing UCMA 4.0..." -ForegroundColor Cyan
    Start-Process -FilePath $UcmaInstaller -ArgumentList "/quiet" -Wait
    Write-Host "UCMA 4.0 installation completed." -ForegroundColor Green
} else {
    Write-Host "UCMA 4.0 is already installed. Skipping installation and download." -ForegroundColor Green
}

Write-Host "All prerequisites handled successfully." -ForegroundColor Magenta

  • Assicurati che Windows Server 2019 o 2022 (ultima patch)
  • Diritti di amministratore (Esegui come amministratore)
  • Accesso a Internet (per scaricare le dipendenze

Apri PowerShell come amministratore

Passare alla cartella dello script ed eseguire lo script

Se hai salvato lo script con il nome ExchangePrerequisites.ps1, esegui il comando seguente

Esempio:

c:scripts> .ExchangePrerequisites.ps1

Una volta avviato lo script, puoi seguire le istruzioni sullo schermo per verificare il processo.

Il software e le funzionalità di Windows verranno scaricati e installati automaticamente.

In che modo è utile automatizzare i prerequisiti di Exchange Server

  • Risparmia ore di configurazione manuale
  • Evita prerequisiti mancati o errori di installazione di Exchange
  • Perfetto per implementazioni di laboratorio, produzione o lavori di consulenza
  • Abbastanza sicuro dato che è un server nuovo, quindi non perdi nulla

Suggerimenti rapidi per la risoluzione dei problemi

Se lo script non è in esecuzione, alloraimpostare la politica di esecuzioneinnanzitutto eseguendo il cmdlet seguente

Set-ExecutionPolicy RemoteSigned -Scope Process

Se la riscrittura dell'URL non riesce, assicurati che IIS sia installato prima

Pertanto, seUCMAnon si installa, controlla la connettività Internet o, se l'URL del software cambia, installalo manualmente.

Nota: tuttavia, questo script installerà prima la funzionalità IIS, in modo che la riscrittura dell'URL non richieda alcun errore

Considerazioni finali

Se stai configurando Exchange Server 2019 e desideri unconfigurazione rapida e senza errori, questo script renderà il tuo lavoro molto più semplice. Aggiungi questa pagina ai segnalibri o iscriviti al mio canale per ulteriori contenuti Exchange, Proxmox e Mailcow.

Spero che ti piaceranno anche alcuni tutorial su Microsoft Exchange

Come rinnovare il certificato della federazione di Exchange

Script di PowerShell per il controllo dell'integrità di Exchange Server

Pertanto, se riscontri problemi con Exchange Server, locale o Hybrid Exchange

Non esitate a contattarci a[e-mail protetta]

Inoltre, puoi vedere ogni passaggio in azione, inclusa l'installazione in tempo reale e cosa fa ciascun componente.

Lettura consigliata:Impossibile aggiungere un server membro DAG in Exchange Server

Related Posts