当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 检查 Exchange 架构版本

作者:精品下载站 日期:2024-12-14 18:11:40 浏览:13 分类:玩电脑

使用 PowerShell 检查 Exchange 架构版本


您想知道您的 Active Directory (AD) 是否是最新的。例如,您想要在升级到较新的 Exchange Server 版本之前和之后检查并验证 Exchange 2013/2016/2019 架构版本。在本文中,您将了解如何使用 PowerShell 检查 Exchange 架构版本。

为什么要检查 Exchange 架构版本信息

最好检查并验证 Exchange 架构版本,例如:

  • 安装 Exchange 累积更新之前

  • 安装新的 Exchange 服务器之前

  • 为 Exchange Server 准备 Active Directory 和域后

使用 PowerShell 命令获取 Exchange 架构版本

以管理员身份运行 PowerShell。一一运行以下命令。

PS C:\> # Exchange Schema Version
PS C:\> $sc = (Get-ADRootDSE).SchemaNamingContext
PS C:\> $ob = "CN=ms-Exch-Schema-Version-Pt," + $sc
PS C:\> Write-Output "RangeUpper: $((Get-ADObject $ob -pr rangeUpper).rangeUpper)"
RangeUpper: 17003
 
PS C:\> # Exchange Object Version (domain)
PS C:\> $dc = (Get-ADRootDSE).DefaultNamingContext
PS C:\> $ob = "CN=Microsoft Exchange System Objects," + $dc
PS C:\> Write-Output "ObjectVersion (Default): $((Get-ADObject $ob -pr objectVersion).objectVersion)"
ObjectVersion (Default): 13242
 
PS C:\> # Exchange Object Version (forest)
PS C:\> $cc = (Get-ADRootDSE).ConfigurationNamingContext
PS C:\> $fl = "(objectClass=msExchOrganizationContainer)"
PS C:\> Write-Output "ObjectVersion (Configuration): $((Get-ADObject -LDAPFilter $fl -SearchBase $cc -pr objectVersion).objectVersion)"
ObjectVersion (Configuration): 16759

使用 Get-ADversions 脚本获取 Exchange 架构版本

下载脚本 Get-ADversions.ps1 并将其保存在 C:\scripts\ 文件夹中。

确保该文件未被阻止,以防止运行脚本时出现任何错误。请阅读文章运行 PowerShell 脚本时出现未数字签名错误来了解更多信息。

另一种选择是将以下代码复制并粘贴到记事本中。将其命名为 Get-ADversions.ps1 并将其放置在 C:\scripts 文件夹中。

# Exchange Schema Version
$sc = (Get-ADRootDSE).SchemaNamingContext
$ob = "CN=ms-Exch-Schema-Version-Pt," + $sc
Write-Output "RangeUpper: $((Get-ADObject $ob -pr rangeUpper).rangeUpper)"

# Exchange Object Version (domain)
$dc = (Get-ADRootDSE).DefaultNamingContext
$ob = "CN=Microsoft Exchange System Objects," + $dc
Write-Output "ObjectVersion (Default): $((Get-ADObject $ob -pr objectVersion).objectVersion)"

# Exchange Object Version (forest)
$cc = (Get-ADRootDSE).ConfigurationNamingContext
$fl = "(objectClass=msExchOrganizationContainer)"
Write-Output "ObjectVersion (Configuration): $((Get-ADObject -LDAPFilter $fl -SearchBase $cc -pr objectVersion).objectVersion)"

以管理员身份运行 PowerShell。确保将执行策略设置为无限制。按YEnter。如果不这样做,脚本将不会运行。

PS C:\> Set-ExecutionPolicy Unrestricted

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the
security risks described in the about_Execution_Policies help topic at http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to
change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y

调整 C:\scripts\ 文件夹的路径并运行 Get-ADversions.ps1 PowerShell 脚本。

PS C:\> cd C:\scripts\
PS C:\scripts> .\Get-ADversions.ps1
RangeUpper: 17003
ObjectVersion (Default): 13242
ObjectVersion (Configuration): 16759

运行 PowerShell 脚本后,您将看到 Active Directory 版本的输出:

  • 范围上限: 17003

  • 对象版本(默认):13242

  • 对象版本(配置): 16759

下一步是检查和验证架构。

检查并验证 Active Directory 版本

如何确认Exchange Active Directory版本?访问交换架构版本页面以获取对象版本列表。

我们可以确认 Exchange 2019 CU11 的 Exchange 2019 架构版本是最新的。

[玩转系统] 使用 PowerShell 检查 Exchange 架构版本

结论

您了解了如何使用 PowerShell 检查和验证 Exchange 架构版本。运行 Get-ADversions.ps1 PowerShell 脚本并检查 Active Directory 版本是否正确显示。

您喜欢这篇文章吗?如果是这样,您可能喜欢 DMZ 或 LAN 网络中的 Exchange Server。不要忘记关注我们并分享这篇文章。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯