Automatizando os pré-requisitos do Exchange Server


Automatizando totalmente os pré-requisitos do Exchange Server com um script do PowerShell

Se você está planejando instalar o Microsoft Exchange Server 2019 e posterior, pense em automatizar os pré-requisitos do Exchange Server para implantá-lo rapidamente. Nós ajudamos você.

A instalação manual do Microsoft Exchange Server consome muito tempo porque é necessário baixar diferentes pacotes de software de diferentes fontes.

Depois de baixá-los e instalá-los, você deve instalar os recursos necessários do Windows e, em seguida, estender o esquema, preparar o AD e todos os domínios.

Fazer isso manualmente leva tempo e, se você perder alguma coisa, a Instalação do Exchange não continuará e solicitará a instalação do recurso ausente.

Neste guia, orientarei você em um script do PowerShell totalmente automatizado que configuratodos os componentes necessáriospara Exchange Server 2019.

Como recursos do Windows, .NET Framework, redistribuíveis C++, UCMA e reescrita de URL.

Isso será feito com a ajuda do script de pré-requisitos do Exchange Server 2019, que é uma compilação totalmente automatizada no PowerShell.

Este script do Exchange PowerShell é rápido, fácil e seguro e, portanto, livre de erros, para automatizar os pré-requisitos do Exchange Server para implantar rapidamente o Exchange Server.

O que o script faz automaticamente

Normalmente, você sabe que existem vários softwares e recursos que precisam ser instalados antes de instalar o servidor Exchange.

Este script cuidará automaticamente da instalação dos seguintes softwares e recursos.

  • Instala o .NET Framework 4.8
  • Instala redistribuíveis do Visual C++ (2012 e 2013)
  • Instala funções e recursos necessários do Windows Server
  • Instala o módulo URL Rewrite
  • Instala UCMA 4.0
  • Garante que você esteja pronto para a preparação do esquema/domínio do Exchange

Portanto, também verifica se algum recurso ou software já está instalado.

No entanto, se encontrar o software e o recurso já instalados, ele irá pular a etapa e prosseguir.

Prepare também automaticamente seu controlador de domínio

Como você sabe, também precisamos instalar o .NET Framework, C++ Redistributables no controlador de domínio, junto com alguns outros recursos do Windows.

Para automatizar isso, você pode executar o script a seguir antes de executar o script Exchange Server Automating Prerequisites.

# 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

Como usar o script de automação de pré-requisitos do Exchange

Você pode copiar o script do trecho abaixo e salvá-lo com qualquer nome com extensão .ps1.

No nosso caso, salvamos dentro da pasta de script na unidade 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

  • Certifique-se de que o Windows Server 2019 ou 2022 (último patch)
  • Direitos de administrador (executar como administrador)
  • Acesso à Internet (para baixar dependências

Abra o PowerShell como administrador

Navegue até a pasta do script e execute o script

Se você salvou o script com o nome ExchangePrerequisites.ps1, execute o seguinte comando

Exemplo:

c:scripts> .ExchangePrerequisites.ps1

Depois que o script for iniciado, você poderá seguir as instruções na tela para verificar o processo.

Ele baixará e instalará automaticamente o software e os recursos do Windows.

Como a automação dos pré-requisitos do Exchange Server ajuda

  • Economiza horas de configuração manual
  • Evita pré-requisitos perdidos ou erros de configuração do Exchange
  • Perfeito para implantações de laboratório, produção ou trabalho de consultoria
  • Bastante seguro, pois é um servidor novo, então você não perde nada

Dicas rápidas para solução de problemas

Se o script não estiver em execução, entãodefinir a política de execuçãoprimeiro executando o seguinte cmdlet

Set-ExecutionPolicy RemoteSigned -Scope Process

Se a reescrita de URL falhar, certifique-se de que o IIS esteja instalado primeiro

Portanto, seUCMAnão estiver sendo instalado, verifique a conectividade com a Internet ou, se o URL do software for alterado, instale-o manualmente.

Nota: No entanto, este script instalará o recurso IIS primeiro, para que a reconfiguração de URL não solicite nenhum erro

Considerações Finais

Se você estiver configurando o Exchange Server 2019 e quiser umconfiguração rápida e sem erros, este script tornará seu trabalho muito mais fácil. Marque esta página ou assine meu canal para obter mais conteúdo do Exchange, Proxmox e Mailcow.

Espero que você também goste de alguns tutoriais do Microsoft Exchange

Saber mais:Atualizações de hotfix do Exchange Server de abril de 2025

Como renovar o certificado da Federação Exchange

Script do PowerShell do verificador de integridade do Exchange Server

Portanto, se você enfrentar qualquer problema com seu Exchange Server, local ou Exchange Híbrido

Não hesite em contactar-nos em[e-mail protegido]

Além disso, veja cada etapa da ação, incluindo a instalação em tempo real e o que cada componente faz.

Related Posts