1. Anasayfa
  2. Microsoft Exchange Server

Exchange Server 2019 Prerequisites Otomasyonu (PowerShell Script ile)


Microsoft Exchange Server kurulumunu manuel olarak yapmak özellikle de farklı yazılım paketlerini indirip kurmak, Windows bileşenlerini yüklemek, ardından Active Directory şemasını genişletmek ve domainleri hazırlamak söz konusu olduğunda oldukça zaman alıcı ve hata riski yüksek bir iştir.

Yanlış ya da eksik bir adım kurulumun Setup ekranında durmasına ve “Prerequisite Analysis FAILED” hatasına yol açar. İşte bu noktada tam otomatik PowerShell script yaklaşımı devreye giriyor.

Bu yöntemle:

  • Windows Server rolleri ve özellikleri,
  • .NET Framework 4.8/4.8.1,
  • Visual C++ Redistributables (2012, 2013),
  • UCMA 4.0,
  • IIS URL Rewrite 2.1

tek seferde otomatik kurulup hazırlanır. Ayrıca script daha önce yüklü olan bileşenleri kontrol ederek idempotent çalışır yani aynı script defalarca çalıştırıldığında yalnızca eksik adımları tamamlar, gereksiz yeniden yükleme yapmaz.

Script’in Yaptıkları

  1. .NET Framework 4.8 veya üstünü kontrol eder ve gerekirse indirip kurar.
  2. Visual C++ Redistributables 2012 & 2013 (x64) paketlerini yükler.
  3. Gerekli Windows Server rolleri ve özelliklerini yükler: IIS, RPC-over-HTTP, WAS, WCF aktivasyonları, Clustering yönetim araçları vb.
  4. IIS URL Rewrite 2.1 modülünü kurar. Bu modül, Exchange 2019 CU11’den beri kurulumun olmazsa olmaz önkoşuludur.
  5. UCMA 4.0’ı yükler (özellikle bazı Skype/Teams entegrasyon senaryoları için).
  6. Active Directory hazırlığı için domain controller üzerinde gerekli bileşenleri yükler ve AD’yi Exchange kurulumuna hazır hale getirir.

Script her adımda kontrol yapar. Eğer .NET, C++ veya bir Windows özelliği zaten yüklüyse, “Skipping…” mesajıyla geçer. Böylece hatasız ve hızlı bir kurulum süreci garanti edilir.

Domain Controller Önkoşullarını Otomatik Hazırlama

Exchange kurulumunda sadece mailbox sunucuları değil, Domain Controller da hazırlanmalıdır. Çünkü AD şeması genişletilirken DC üzerinde de belirli bileşenler bulunmalıdır.

Aşağıdaki örnek script:

  • .NET Framework 4.8,
  • Visual C++ 2012/2013,
  • RSAT-ADDS gibi gerekli Windows bileşenlerini DC üzerine kurar.

Örnek Script Parçası (DC için)

# Active Directory Prerequisites Full Installer

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:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
        "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    )
    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:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" -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:TEMP\ndp48-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:TEMP\vcredist2012_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:TEMP\vcredist2013x64.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

Bu script ile;

Hızlı ve hatasız kurulum: 30–40 dakikalık manuel iş, 5–10 dakikaya iner.
Tekrarlanabilirlik: Aynı script farklı ortamlarda kullanılabilir.
Otomatik kontrol: Önceden yüklü bileşenleri atlayarak zaman kazandırır.
Domain Controller hazırlığını da kapsar: AD tarafındaki eksiklikler önceden tamamlanır.

Exchange Server kurulumu sırasında en çok zaman alan kısım gerekli Windows Server rollerini, .NET Framework, Visual C++ Redistributables, UCMA 4.0 ve IIS URL Rewrite gibi bileşenleri tek tek indirip kurmaktır.

Elle yapıldığında:

  • Farklı paketleri farklı Microsoft sayfalarından indirmen gerekir.
  • Sürüm uyumsuzluğu veya eksik kurulum, Setup ekranında Prerequisite Failed hatası ile karşılaşmana neden olur.
  • Kurulumun devam etmesi için tek tek eksikleri tamamlaman gerekir.

Bu sorunu ortadan kaldırmak için, tam otomatik PowerShell script ile tüm önkoşulları tek seferde kurabilir, hiçbir adımı atlamadan Exchange Server ortamını hazırlayabilirsin.

Scritp İçeriği;

# Exchange Server 2019 Prerequisites Full Installer

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:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
        "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    )
    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:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" -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:TEMP\ndp48-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:TEMP\vcredist2012_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:TEMP\vcredist2013x64.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:SystemRoot\System32\inetsrv\rewrite.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:TEMP\rewrite_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 Files\Microsoft 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:TEMP\UcmaRuntimeSetup.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

Script Nasıl Çalışır?

  1. .NET Framework 4.8 veya üstünü kontrol eder. Eksikse indirip kurar.
  2. Visual C++ 2012 ve 2013 (x64) Redistributables paketlerini yükler.
  3. Gerekli Windows Server rollerini ve özelliklerini kurar (IIS, WCF aktivasyonları, clustering araçları, RPC-over-HTTP vb.).
  4. IIS URL Rewrite Module 2.1 indirip kurar.
  5. UCMA 4.0 Runtime’ı yükler (Unified Communications Managed API).
  6. Her adımdan önce kontrol yaparak, daha önce kurulu olan bileşenleri atlar (idempotent çalışma mantığı).

Script’in Kullanımı

Script’i Kaydetme

  • Script kodunu kopyala.
  • ExchangePrerequisites.ps1 adıyla kaydet (ör. C:\scripts\ExchangePrerequisites.ps1).

Çalıştırma Öncesi Gereksinimler

  • Windows Server 2019 veya 2022 (tüm güncellemeler yapılmış olmalı).
  • Local Administrator yetkileri.
  • İnternet bağlantısı (Microsoft paketlerini indirmek için).
  • PowerShell’i Run as Administrator aç.

Script’i Çalıştırma

Script klasörüne git ve aşağıdaki komutu çalıştır:

cd C:\scripts
.\ExchangePrerequisites.ps1

Çalıştırdığında script otomatik olarak gerekli bileşenleri indirip kurmaya başlar. Ekranda adım adım hangi paketlerin kurulduğunu veya atlandığını görebilirsin.

Kurulum Akışı

  • .NET Framework 4.8 yükleniyor → Eksikse indirip kurar.
  • Visual C++ 2012 ve 2013 yükleniyor → Daha önceden varsa atlar.
  • Windows Features kuruluyor → Exchange için gerekli IIS, WCF, clustering, authentication vb. özellikler yüklenir.
  • IIS URL Rewrite kuruluyor → IIS olmadan yüklenmez, script önce IIS’i kurduğu için hata almazsın.
  • UCMA 4.0 indiriliyor ve kuruluyor.

En sonunda:
“All prerequisites handled successfully.” mesajını görürsün.

  • Script çalışmazsa → Execution Policy’yi ayarla: Set-ExecutionPolicy RemoteSigned -Scope Process
  • URL Rewrite yüklenmezse → IIS’in kurulu olduğundan emin ol (script zaten otomatik yükler).
  • UCMA kurulmazsa → İnternet bağlantını kontrol et veya Microsoft indirme linki değişmişse manuel indirip kur.