Automatización de requisitos previos de Exchange Server


Automatización completa de los requisitos previos del servidor Exchange con un script de PowerShell

Si planea instalar Microsoft Exchange Server 2019 y versiones posteriores, piense en automatizar los requisitos previos de Exchange Server para implementarlo rápidamente. Lo tenemos cubierto.

La instalación manual de Microsoft Exchange Server consume mucho tiempo porque hay que descargar los diferentes paquetes de software de diferentes fuentes.

Después de descargarlos e instalarlos, debe instalar las funciones requeridas de Windows y luego ampliar el esquema, preparar AD y todos los dominios.

Hacer esto manualmente lleva tiempo y, si omite algo, la configuración de Exchange no continuará y le solicitará que instale la función que falta.

En esta guía, lo guiaré a través de un script de PowerShell totalmente automatizado que configuratodos los componentes necesariospara servidor Exchange 2019.

Como funciones de Windows, .NET Framework, redistribuibles de C++, UCMA y reescritura de URL.

Esto se hará con la ayuda del script de requisitos previos de Exchange Server 2019, que es una compilación totalmente automatizada en PowerShell.

Este script de Exchange PowerShell es rápido, fácil y seguro, por lo tanto, libre de errores, para automatizar los requisitos previos de Exchange Server para implementar rápidamente Exchange Server.

Qué hace el script automáticamente

Por lo general, usted sabe que hay varios programas y funciones que deben instalarse antes de instalar el servidor Exchange.

Este script se encargará automáticamente de instalar el siguiente software y funciones.

  • Instala .NET Framework 4.8
  • Instala redistribuibles de Visual C++ (2012 y 2013)
  • Instala las funciones y funciones requeridas de Windows Server
  • Instala el módulo de reescritura de URL
  • Instala UCMA 4.0
  • Garantiza que esté listo para la preparación del esquema/dominio de Exchange

Por lo tanto, también comprueba si alguna función o software ya está instalado.

Sin embargo, si encuentra el software y la función ya instalados, omitirá el paso y continuará.

Prepare también automáticamente su controlador de dominio

Como sabe, también tenemos que instalar .NET Framework, C++ Redistributables en el controlador de dominio, junto con algunas otras características de Windows.

Para automatizar esto, puede ejecutar el siguiente script antes de ejecutar el script de requisitos previos de automatización de 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

Cómo utilizar el script de automatización de requisitos previos de Exchange

Puede copiar el script del siguiente fragmento y guardarlo con cualquier nombre con una extensión .ps1.

En nuestro caso, lo guardamos dentro de la carpeta del script en la unidad 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

  • Asegúrese de que Windows Server 2019 o 2022 (último parche)
  • Derechos de administrador (Ejecutar como administrador)
  • Acceso a Internet (para descargar dependencias

Abra PowerShell como administrador

Lectura sugerida:Actualizaciones de revisiones de Exchange Server de abril de 2025

Navegue a la carpeta del script y ejecute el script.

Si guardó el script con el nombre ExchangePrequires.ps1, ejecute el siguiente comando

Ejemplo:

c:scripts> .ExchangePrerequisites.ps1

Una vez que se inicia el script, puede seguir las instrucciones en pantalla para verificar el proceso.

Descargará e instalará automáticamente el software y las funciones de Windows.

Cómo ayuda la automatización de los requisitos previos del servidor Exchange

  • Ahorra horas de configuración manual
  • Evita requisitos previos omitidos o errores de configuración de Exchange
  • Perfecto para implementaciones de laboratorio, producción o trabajos de consultoría
  • Bastante seguro ya que es un servidor nuevo, por lo que no pierdes nada.

Consejos rápidos para solucionar problemas

Si el script no se está ejecutando, entoncesestablecer la política de ejecuciónprimero ejecutando el siguiente cmdlet

Set-ExecutionPolicy RemoteSigned -Scope Process

Si la reescritura de URL falla, asegúrese de que IIS esté instalado primero

Por lo tanto, siUCMAno se está instalando, verifique la conectividad a Internet o, si la URL del software cambia, instálelo manualmente.

Nota: Sin embargo, este script instalará primero la función IIS, de modo que la reescritura de URL no generará ningún error.

Pensamientos finales

Si está configurando Exchange Server 2019 y desea unaconfiguración rápida y sin errores, este script hará tu trabajo mucho más fácil. Marque esta página o suscríbase a mi canal para obtener más contenido de Exchange, Proxmox y Mailcow.

Espero que también te gusten algunos tutoriales de Microsoft Exchange.

Cómo renovar el certificado de la Federación de Exchange

Secuencia de comandos de PowerShell del Comprobador de estado del servidor Exchange

Por lo tanto, si tiene algún problema con su servidor Exchange, local o Exchange híbrido

No dude en contactarnos en[correo electrónico protegido]

Además, vea cada paso en acción, incluida la instalación en tiempo real y lo que hace cada componente.

Related Posts