Skip to content

/errors/active-directory/get-aduser-is-not-recognized

The term 'Get-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
Active Directory PowerShell
exit code
1
versions
ActiveDirectory module (RSAT), Windows PowerShell 5.1, PowerShell 7 on Windows
os
windows

Get-ADUser : The term 'Get-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program. means PowerShell found no module that provides Get-ADUser. The cmdlet belongs to the ActiveDirectory module, which ships with the Remote Server Administration Tools (RSAT), not with Windows PowerShell itself and not with the PowerShell Gallery. Install RSAT on the machine where the command runs, then open a new PowerShell window.

powershell
# Windows 10/11, elevated PowerShell
Get-WindowsCapability -Online -Name 'Rsat.ActiveDirectory.DS-LDS.Tools*' | Add-WindowsCapability -Online

The same error appears for every cmdlet of the module: Get-ADGroupMember, Get-ADComputer, Set-ADUser, Search-ADAccount, Unlock-ADAccount.

Reproduce it

Windows PowerShell 5.1 on a computer without RSAT:

powershell
try {
  Get-ADUser -Identity jdoe -ErrorAction Stop
} catch {
  $_.Exception.Message
  $_.FullyQualifiedErrorId
}
'Command available: ' + [bool](Get-Command Get-ADUser -ErrorAction SilentlyContinue)

Output

The term 'Get-ADUser' 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.
CommandNotFoundException
Command available: False

CommandNotFoundException is raised before anything is sent to a domain controller, so it is never a permissions or network problem.

Check which part is missing

powershell
Get-Module -ListAvailable ActiveDirectory      # nothing = RSAT not installed
Get-Command Get-ADUser -ErrorAction SilentlyContinue
$PSModuleAutoLoadingPreference                 # 'None' disables auto-loading
  • No module listed: install RSAT (Windows 10/11) or Install-WindowsFeature RSAT-AD-PowerShell (Windows Server). Windows Home editions cannot install RSAT.
  • Module listed but cmdlet not found: auto-loading is off; add Import-Module ActiveDirectory.
  • Works interactively, fails in a job or on a build agent: the job runs on another machine or account; install RSAT there or use Invoke-Command -ComputerName mgmt01 -ScriptBlock { Get-ADUser jdoe }.

Make scripts fail with a clear message

powershell
Import-Module ActiveDirectory -ErrorAction Stop
Get-ADUser -Identity jdoe -Properties LastLogonDate

With an explicit Import-Module, a machine without RSAT stops at the first line with the specified module 'ActiveDirectory' was not loaded, which points directly at the cause. For the general form of this error with any command, see the term is not recognized as the name of a cmdlet.

Sources