Get-aduser not recognized

In this Azure AD tutorial, we will discuss how to fix an error the term ‘get-aduser’ is not recognized as the name of a cmdlet that comes while trying to retrieve users from the Azure active directory.

Recently, I was trying to retrieve the lists of users from my Azure Active Directory using PowerShell. I was executing the Get-aduser PowerShell command as mentioned below.

Get-ADUser

After executing the above command, I got this get-aduser is not recognized error.

The complete error message was as follows:

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
  • ~~
    • CategoryInfo : ObjectNotFound: (get-aduser: String) [], CommandNotFoundException
    • FullyQualifiedErrorId: CommandNotFoundException
get-aduser not recognized

Solution

Try the solutions below to fix your issue.

Solution-1

If you are using Windows 11 or higher versions, then try out this solution.

Open the PowerShell ISE and run the below PowerShell command to install the Active Directory module.

Get-WindowsCapability -Name RSAT.ActiveDirectory* -Online | Add-WindowsCapability -Online

After executing the above PowerShell command, it will start the installation like below

get-aduser : the term 'get-aduser' is not recognized as the name of a cmdlet

Now, after the successful installation, you will get the below output

PS C:\WINDOWS\system32> Get-WindowsCapability -Name RSAT.ActiveDirectory* -Online | Add-WindowsCapability -Online


Path          : 
Online        : True
RestartNeeded : False

You can see the same output in the below screenshot.

the term get-aduser is not recognized

Now try running the Get-ADUser PowerShell command. This time, you won’t get any error. If you are still facing the same issue, then try out the below solution.

Solution -2

The first step you need to try out is enabling the Active Directory Module for Windows Powershell feature in your machine. Follow the below steps to enable the Active Directory Module for Windows Powershell option.

  1. Click on the start menu on your machine and then search for “Windows features.”
  2. Now, the next step is to click on “Turn Windows features on or off”
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.

3. Then you need to Expand the Remote Server Administration Tools option.

4. Now, Again Expand Role Administration Tools option

5. Then, Expand the AD DS and AD LDS Tools option

6. Make sure to tick the checkbox for Active Directory Module for the Windows Powershell option

7. Now, You need to confirm that it’s okay to install the feature

If the above solution doesn’t work for you, then there is nothing to worry about. Try out the solution below

Solution – 3

  1. Open the Window PowerShell or PowerShell ISE with Run as Administrator mode.
powershell get-aduser not recognized

2. Run the below PowerShell command to find out the path for your PowerShell Profile where it is located.

PS C:\WINDOWS\system32> $profile

You can see that it returned me with the below path

C:\Users\Bijay\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

the term 'get-aduser' is not recognized as the name of a cmdlet,

3. The next step is to navigate to C:\Users\Bijay\Documents\. You will not find a folder with the name WindowsPowerShell.

Since the folder is not present, create a folder with the name WindowsPowerShell, then you can use the text editor to create a file called Microsoft.PowerShell_profile.ps1 and add the below line

import-module activedirectory

Now, make sure to save the file and then close all your Open PowerShell Sessions. Now, This solution should work for you. You can run the script now. It should not give any error this time.

Solution -4

If you are getting the error that the term ‘get-aduser’ is not recognized as the name of a cmdlet while working in PowerShell in Windows 10, Windows Server 2016 or Windows Server 2012/2012 R2, and the above solutions didn’t work for you then run the below steps to fix it:

Open the Windows command prompt as an administrator and run the below command.

import-module ActiveDirectory
get-aduser not recognized windows 10

Once you have installed it, you can verify by running the below command:

get-module -listavailable

Now, you will not get the error if you will try to execute the Active Directory command get-aduser.

In the case of Windows 10 PowerShell [Solved]

Now, let me tell you the mistake I was making.

A very silly mistake.

I was trying to get users from Azure Active Directory using PowerShell in Windows 10.

In my case, I was using the Active Directory command (get-aduser) rather than the Azure Active Directory command (Get-AzADUser) to retrieve the users from Azure AD.

When I run the below command:

Get-AzADUser

Note: We will not have AD configured in the local windows 10 system.

In the case of Windows 2008 server

If you use a Windows 2008 server, follow the steps below to fix the issue.

The first step is, to check if the Azure Active Directory module is present using the below PowerShell cmdlet

PS C:\WINDOWS\system32> get-module -listavailable
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.

Once you run the above command, you should able to see the Azure Active Directory module present on your machine, then run the below PowerShell cmdlet as the next step

PS C:\WINDOWS\system32> import-module activedirectory

If the Azure Active Directory module is not present and you are using the Windows 2008 server, then before running the above command, you need to install the Azure Active Directory module.

In the case of Windows Server 2008 R2

If you are using Windows Server 2008 R2, then the Azure Active Directory module is by default, present in your machine. You must install it using the below PowerShell cmdlet in the same Order.

Note: Ensure the Active Directory Web Services (ADWS) is installed on your machine.

Import-Module ServerManager
Add-WindowsFeature RSAT-AD-PowerShell

Once you install the Azure Active Directory module on your machine, run the below PowerShell cmdlet.

Check if the Azure Active Directory module is present using the below PowerShell cmdlet

PS C:\WINDOWS\system32> get-module -listavailable

Then run the below PowerShell cmdlet as the next step

PS C:\WINDOWS\system32> import-module activedirectory

In the case of Windows 7

If you are using Windows 7 and you got this error, then below are the steps that can help you to fix the issue.

  1. Navigate to the Control Panel and open it -> click on the Programs and Features -> Turn On/Off Windows Features.
  2. Then, you need to find out “Remote Server Administration Tools” and expand it.
  3. Now, Expand the “Role Administration Tools” node.
  4. Then, Expand the AD DS and AD LDS Tools options.
  5. Make sure to tick the checkbox for Active Directory Module for Windows Powershell option.
  6. Finally, click on the OK button to confirm the installation.

Note: One important point to note here is that if you are using Windows 10 and cannot see the “Remote Server Administration Tools” option in your system, then you need to install the RSAT tools for Windows 10 using the below steps.

  1. Download the Remote Server Administration Tools for Windows 10 now and install it on your machine.
  2. Once you have installed the RSAT tools, restart your machine once to reflect the changes in your machine. Now, you can enable the Active Directory Module for Windows Powershell option using the above steps.

You may like the following Azure tutorials:

Wrapping Up

I hope this Azure tutorial helps you to fix the below error on Windows 7, Windows 10, Windows Server 2016, or Windows Server 2012/2012 R2, etc

  • The term ‘get-aduser’ is not recognized as the name of a cmdlet

I hope You have enjoyed this Article !!!

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!