自动化交换服务器先决条件
使用PowerShell脚本完全自动化的Exchange Server先决条件
如果您打算安装Microsoft Exchange Server 2019及以后,则考虑自动化Exchange Server的先决条件来快速部署它。我们已经覆盖了你。
安装Microsoft Exchange Server手动消耗了很多时间,因为您必须从不同来源下载不同的软件包。
下载并安装它们后,您必须安装所需的Windows功能,然后扩展模式,准备AD和所有域。
手动执行此操作需要时间,如果您错过任何东西,Exchange设置将不会继续并提示安装缺失的功能。
在本指南中,我将带您浏览一个完全自动化的PowerShell脚本,该脚本设置所有必要的组件对于Exchange Server 2019。
例如Windows功能,.NET框架,C ++重新分布物,UCMA和URL重写。
这将在Exchange Server 2019先决条件脚本的帮助下完成,该脚本是PowerShell的全自动构建。
有关的:2025年4月Exchange Server Hotfix更新
此Exchange PowerShell脚本是快速,容易且安全的,因此无错误,用于自动化Exchange服务器的先决条件,以快速部署Exchange Server。
脚本自动做什么
通常,您知道在安装Exchange服务器之前需要安装多个软件和功能。
该脚本将自动考虑安装以下软件和功能。
- 安装.NET框架4.8
- 安装Visual C ++重新分布物(2012&2013)
- 安装所需的Windows服务器角色和功能
- 安装URL重写模块
- 安装UCMA 4.0
- 确保您准备好进行交换模式/域准备
因此,它还检查是否已经安装了某些功能或软件。
但是,如果它找到了软件并已经安装了功能,它将跳过步骤并进一步继续。
也会自动准备域控制器
如您所知,我们还必须在域控制器上安装.NET框架,C ++重新分布物以及其他一些Windows功能。

为了自动化,您可以在运行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
如何使用Exchange先决条件自动脚本
您可以从下面的摘要中复制脚本,并使用任何名称保存在.ps1扩展程序中。
在我们的情况下,我们将其保存在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
- 确保Windows Server 2019或2022(最新修补)
- 管理员权利(作为管理员运行)
- 互联网访问(下载依赖项
打开PowerShell作为管理员
导航到脚本文件夹并运行脚本
如果您以ExchangePrerecites.ps1的名称保存脚本,请运行以下命令
例子:
c:scripts> .ExchangePrerequisites.ps1
脚本启动后,您可以按照屏幕提示进行检查。
它将自动下载并安装软件和Windows功能。


自动化交换服务器的先决条件如何帮助
- 它节省了数小时的手动配置
- 避免错过先决条件或交换设置错误
- 非常适合实验室部署,生产或咨询工作
- 非常安全,因为它是一台新鲜的服务器,所以您什么都不会损失
快速故障排除提示
如果脚本不运行,则设定执行策略首先运行以下CMDLET
Set-ExecutionPolicy RemoteSigned -Scope Process
如果URL重写失败,请确保先安装IIS
因此,如果UCMA没有安装,检查Internet连接,或者如果软件的URL更改,请手动安装。
注意:但是,此脚本将首先安装IIS功能,因此URL重写不会提示任何错误
最后的想法
如果您要设置Exchange Server 2019,并想要一个快速,无错误的设置,此脚本将使您的工作变得更加容易。在此页面上添加书签或订阅我的频道以获取更多交换,proxmox和mailcow内容。
希望您还会喜欢一些Microsoft Exchange教程
如何续订交换联合会证书
Exchange Server Health Checker PowerShell脚本
因此,如果您遇到了交换服务器,本地或混合交换的任何问题
随时与我们联系[电子邮件保护]
此外,请查看行动中的每个步骤,包括实时安装以及每个组件的作用。
