Server 2012 r2 上的 Powershell 無法辨識“unlock-adaccount”

Server 2012 r2 上的 Powershell 無法辨識“unlock-adaccount”

我正在嘗試在 Windows Server 2012 R2 機器上執行的 powershell 腳本中使用 Unlock-ADAccount。這就是我得到的:

PS C:\> unlock-adaccount
unlock-adaccount : The term 'unlock-adaccount' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or if a path 
was included, verify that the path is correct and try again.
At line:1 char:1

我確實找到了一個SpiceWorks 線程這表示需要安裝 RSAT,但它適用於 Windows 10。

答案1

這需要遠端伺服器管理工具 (RSAT),可以透過以下 PowerShell 命令安裝該工具: Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online

安裝完成後,您可以使用下列 PowerShell 指令載入 Active Directory PowerShell:Import-Module ActiveDirectoryIPMO ActiveDirectory

完成後,Unlock-ADAccount可以與相關 RSAT 模組的其他指令一起使用

答案2

我想我只是傻了。我查看了伺服器管理員,在“功能”->“遠端伺服器管理工具”->“角色管理工具”->“AD DS 和AD LDS 工具”下,只需單擊“為Windows PowerShell 啟用Active Directory 模組」。

相關內容