/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
- 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.
# 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-PowerShellReproduce it
On a computer without RSAT (Windows PowerShell 5.1):
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
| Windows | How 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 later | Install-WindowsFeature RSAT-AD-PowerShell (Server Manager: Features > Remote Server Administration Tools > AD DS and AD LDS Tools) |
| Domain controllers | Installed with the AD DS role |
| Windows Home editions | Not 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:
Get-Module -ListAvailable ActiveDirectory
Import-Module ActiveDirectory
Get-ADDomainPowerShell 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
- learn.microsoft.comlearn.microsoft.com/en-us/troubleshoot/windows-server/system-management-components/remote-server-administration-tools
- learn.microsoft.comlearn.microsoft.com/en-us/powershell/module/activedirectory/
- learn.microsoft.comlearn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/import-module