您的位置首页百科知识

如何安装PowerShell Active Directory模块

如何安装PowerShell Active Directory模块

的有关信息介绍如下:

如何安装PowerShell Active Directory模块

在PowerShell的Active Directory模块提供了各种的cmdlet,使您可以远程管理Active Directory的。

那您想知道如何在Windows 7,Windows 8,Windows 8.1,Windows Server 2008 R2和Windows Server 2012 R2上安装PowerShell Active Directory模块吗?

Active Directory模块是远程服务器管理工具(RSAT)的一部分,您必须首先下载。然后安装到您需要存放的位置。

安装完成后,打开控制面板,开始输入“功能”,然后单击打开或关闭Windows功能。向下滚动到远程服务器管理工具,并在远程服务器管理工具>角色管理工具> AD DS和AD LDS工具中为Windows PowerShell启用Active Directory模块。

如果您从Active Directory模块运行诸如Get-ADUser的cmdlet,您将收到错误消息“Get-ADUser”一词不会被识别为cmdlet的名称...“即使该模块已安装。

原因是Windows 7中的PowerShell 2不支持自动cmdlet发现和模块加载,因此您必须手动导入Active Directory模块。如果您已经更新到PowerShell 3或更高版本,则无需遵循以下步骤。要导入模块,必须在PowerShell提示符下键入以下内容:

Import-Module ActiveDirectory

另一个选项是从控制面板中的“管理工具”文件夹打开该模块。

不幸的是,这还不足以完全安装Active Directory模块。我们迄今为止所做的一切都是运行模块。如果启动新的PowerShell会话,该模块将不会再次加载。要使模块导入成为永久性,您必须在PowerShell配置文件中运行import命令。

如果要仅为您的帐户导入模块,可以将命令Import-Module ActiveDirectory添加到%UserProfile%\ My Documents \ WindowsPowerShell \ profile.ps1。这也将自动导入PowerShell ISE中的模块。如果您只想在PowerShell控制台中导入模块,则可以将上述命令添加到Microsoft.PowerShell_profile.ps1。

请注意,只有您的PowerShell执行策略设置为RemoteSigned或Unrestricted,您的配置文件脚本才会运行。如果您没有更改默认执行策略,可以使用以下命令进行配置:

Set-ExecutionPolicy RemoteSigned

如果您的Windows Server 2008 R2计算机是域控制器,则PowerShell Active Directory模块已安装。您只需要在成员服务器上安装该模块。Windows Server 2008 R2中的过程与Windows 7中的过程类似。(请注意,该模块不适用于Windows Server 2008)。

一个区别是,您不必下载RSAT,因为这些工具已经在Windows Server 2008 R2上可用。在服务器管理器中,您必须单击添加功能,然后在远程服务器管理工具>角色管理工具> AD DS和AD LDS工具中为Windows PowerShell选择Active Directory模块。

或者,您可以从PowerShell控制台安装模块:

Import-Module ServerManager

Add-WindowsFeature RSAT-AD-PowerShell

将模块复制到计算机后,必须将其导入:

Import-Module ActiveDirectory

或者,您可以右键单击任务栏中的PowerShell图标,然后选择导入系统模块。

在Windows 7上,如果要使导入永久,则必须将上述import命令添加到PowerShell配置文件中。请注意,此描述假定您没有在Windows Server 20o8 R2计算机上更新PowerShell 2

Windows 8和Windows 8.1中的事情要容易得多。

所有你需要做的是下载(Windows 8,Windows 8.1)并安装RSAT。默认情况下,所有工具都在安装后启用,您也不需要导入模块。您可以在安装RSAT后立即使用Active Directory模块。所以,再也没有传播这个神话,Windows 7比Windows 8更好。

在Windows Server 2008 R2上,Active Directory模块已经安装在Windows Server 2012和Windows Server 2012 R2上的域控制器上。

在成员服务器上,您可以将模块作为功能添加到服务器管理器中。在远程服务器管理工具>角色管理工具> AD DS和AD LDS工具中为Windows PowerShell启用Active Directory模块。

或者,您可以从PowerShell控制台安装模块:

Add-WindowsFeature RSAT-AD-PowerShell

无需首先导入ServerManager模块,就像Windows Server 2008 R2一样。您也不必在安装后导入Active Directory模块。