Skip to content

/errors/active-directory/import-module-activedirectory-no-valid-module-file

Import-Module : The specified module 'ActiveDirectory' was not loaded because no valid module file was found

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

Import-Module : The specified module 'ActiveDirectory' was not loaded because no valid module file was found in any module directory. means the Active Directory module for Windows PowerShell is not installed on this computer. It is not in the PowerShell Gallery: it ships with the Remote Server Administration Tools (RSAT). Install the RSAT capability on Windows 10/11 or the RSAT-AD-PowerShell feature on Windows Server, open a new PowerShell window, and import it again.

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

# Windows Server, elevated PowerShell
Install-WindowsFeature RSAT-AD-PowerShell

Reproduce it

On a computer without RSAT (Windows PowerShell 5.1):

powershell
try {
  Import-Module ActiveDirectory -ErrorAction Stop
} catch {
  $_.Exception.Message
  $_.FullyQualifiedErrorId
}
'Module available: ' + [bool](Get-Module -ListAvailable -Name ActiveDirectory)

Output

The specified module 'ActiveDirectory' was not loaded because no valid module file was found in any module directory.
Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Module available: False

Get-Module -ListAvailable returning nothing confirms that no folder in $env:PSModulePath contains the module; the error is about installation, not about the domain or your permissions.

Install RSAT

WindowsHow to install the ActiveDirectory module
Windows 10 1809+ and Windows 11 (Pro, Enterprise, Education)Settings > System > Optional features > "RSAT: Active Directory Domain Services and Lightweight Directory Services Tools", or Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
Windows Server 2016 and laterInstall-WindowsFeature RSAT-AD-PowerShell (Server Manager: Features > Remote Server Administration Tools > AD DS and AD LDS Tools)
Domain controllersInstalled with the AD DS role
Windows Home editionsNot supported: use a Pro or Enterprise machine or a management server

Add-WindowsCapability downloads the payload from Windows Update. On devices that get updates from WSUS or Configuration Manager the download can fail; Microsoft's RSAT troubleshooting article covers the policy setting and the Features on Demand media for that case. See install RSAT on Windows 11 for the full steps.

After installing, open a new PowerShell window and check:

powershell
Get-Module -ListAvailable ActiveDirectory
Import-Module ActiveDirectory
Get-ADDomain

PowerShell 7 and other platforms

PowerShell 7 on Windows loads the same RSAT module from the Windows module folder, so the fix is the same. On Linux and macOS the module does not exist; run Active Directory cmdlets on a Windows management host, for example through Invoke-Command -ComputerName mgmt01 -ScriptBlock { Get-ADUser jdoe }.

Once the module loads, the next common error is that it cannot reach a domain controller: Unable to find a default server with Active Directory Web Services running.

Sources