PowerShell Genie

PowerShell: command not recognized

Error 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Check spelling, command discovery and required modules when PowerShell says a command is not recognized.

What it means

PowerShell could not resolve the requested command name in the current session. A spelling error, missing module or unavailable executable path can cause this. The failed command did not run; earlier script statements may already have completed.

Likely causes

  • The RSAT Active Directory tools were never installed on this machine
  • The ActiveDirectory module exists on disk but has not been imported into this session
  • The session is PowerShell 7 and the module directory belongs only to the Windows PowerShell 5.1 path
  • The name is misspelled, for example Get-ADUsers with a trailing s

Check

1PS> Get-Command Get-ADUser -All
2PS> Get-Module -ListAvailable ActiveDirectory
3PS> $env:PSModulePath -split ';'

Run these checks before changing anything.

What these checks establish

Get-Command should return command metadata, not user records. If it cannot find Get-ADUser, inspect whether Get-Module -ListAvailable finds ActiveDirectory in this session. An empty module listing is evidence about discovery, not proof that no copy exists anywhere on disk.

Fix

Check spelling and Get-Command -All first. PowerShell normally autoloads discoverable modules, so a missing explicit Import-Module is not itself the diagnosis. Compare PSModulePath, edition and module availability. Install the supported RSAT or server AD tools when absent; if the module is found but import fails, investigate that load error separately.

Verify: In a clean session, confirm Get-Command Get-ADUser reports the intended module, then run a limited authorized query.

Reference

Microsoft Learn: get-command

Continue
Genie guidePowerShell: command not recognized

Check spelling, command discovery and required modules when PowerShell says a command is not recognized.