I'm trying to retrieve few info from my AD users, with the following command on PowerShell:
get-aduser -identity username -Properties * | select DisplayName, City, State
But it gives me this error:
get-aduser : 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.
At line:1 char:1
get-aduser -identity username -Properties * | select DisplayName, Cit ...
~~~~~~~~~~
CategoryInfo : ObjectNotFound: (get-aduser:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
I also tried adding this import:
Import-Module ActiveDirectory
But I instead get this other error:
Import-Module : The specified module 'ActiveDirectory' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
Import-Module ActiveDirectory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ResourceUnavailable: (ActiveDirectory:String) [Import-Module], FileNotFoundException
FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
What am I doing wrong?
CodePudding user response:
You need to install RSAT Tools in order to use the ActiveDirectory
module.
If you have Windows 10 October 2018 Update
or later installed, you can install RSAT Tools as a Windows Feature:
Note: The sample below doesn't use the direct name since there is a version suffix at the end of the name.
Get-WindowsCapability -Online | Where-Object { $_.Name -like "Rsat.ActiveDirectory.DS-LDS.Tools*" } | Add-WindowsCapability -Online
Otherwise, you can install RSAT Tools from the link I provided earlier. Directions are included there for how to install manually for still-supported versions of Windows.