다음을 통해 공유


How to add Active Directory module in PowerShell in Windows 7

If you are planning to run a Powershell script with Active Directory commandlets on a Win 7 machine or any other machine that DOES NOT have AD role then you need to do some preliminary steps as listed below.

 

Step1:

 

By default one can not import Active Directory module in Powershell in Windows 7. You need to do either of the below:
 

 

By doing this you will get the Active directory module to be used in the Power shell scripting.

 

In this article I have explained the steps for Windows 7.

 

Step2:

 

After the installation of the KB958830 go to Windows Feature and enabled the highlighted items as below.

Comments

  • Anonymous
    January 18, 2012
    The comment has been removed

  • Anonymous
    January 31, 2012
    Microsoft Scripting Guy Ed Wilson here. Last week’s Windows PowerShell workshop in Seattle was a lot of fun. The students were really engaged and asked some great questions. My friend from Philadelphia, Pennsylvania, is out there this week doing an Exchange workshop. Anyway, during the class, I decided it would be a good idea to use Windows PowerShell remoting to perform Active Directory administration. In this way, I avoided the need to install the Remote Server Administration Tools (RSAT) on the client machine. The first thing to do is to enter a remote Windows PowerShell session. To do this I use the Enter-PSSession cmdlet. I specify the computername and the credentials for the remote session. The credentials is an account that has the administrator rights on the remote machine. This command is shown here: Enter-PSSession -ComputerName dc1 –credential nwtradersadministrator If I the account I am using for my client computer also has administrator rights on the remote machine, I can leave off the credential parameter. After I have entered the session, I generally set my working location to the root of the drive so that I have more space for my commands. I then import  the ActiveDirectory module. These commands appear are shown here: Set-Location c: Import-Module activedirectory The commands and the associated output are shown in the following image. Note how I use the aliases for the commands because it makes it easier to type. Now I will create a new user in Active Directory. I think I will name the user ed. The command to create a new user is simple; it is New-ADUser and the user name. The command to create a disabled user account in the users container in the default domain is shown here: new-aduser -name ed When the preceding command that creates a new user has completed, nothing is returned to the Windows PowerShell console. To check to ensure the user is created, use the Get-ADUser cmdlet to retrieve the user object: Get-aduser ed When I am certain my new user is created, I decide to create an organizational unit (OU) to store the user account. The command to create a new OU off the root of the domain is shown here: new-ADOrganizationalUnit scripting Just as with the previously used New-ADUser cmdlet, nothing is returned to the Windows PowerShell console. If I use the Get-ADOrganizationalUnit cmdlet, I must use a different methodology. A simple Get-ADOrganizationalUnit command returns an error; therefore, I use an LDAPFilter parameter to find the OU. The command using the LDAPFilter parameter to find my newly created OU is shown here: Get-ADOrganizationalUnit –LDAPFilter "(name=scripting)" The commands and associated output to create the user, get the user, create the OU, and get the OU are shown in the following figure.

  • Anonymous
    April 11, 2012
    Thanks RameshRK, it worked beautifully (on Windows 7 x64) and helped me understand my AD groups.

  • Anonymous
    November 07, 2012
    Hi. this wont work @ win7 x86 PS C:Usersfunio> Import-Module activedirectory Import-Module : The specified module 'activedirectory' was not loaded because no valid module file was found in any mod ule directory. i have the same problem @ Server 2008 STD (old EBS 2008)

  • Anonymous
    April 23, 2013
    In order to install the Active Directory Module for Windows PowerShell you need to

  1.  Download the RSAT tools for Windows 7.
  2.  Navigate to Control Panel > Programs and Features > Turn Windows Features On or Off and select Active Directory Module for Windows PowerShell
  • Anonymous
    May 06, 2013
    Is there anyway to make the module always available for use when I start powershell?

  • Anonymous
    May 16, 2013
    The comment has been removed

  • Anonymous
    May 23, 2013
    %windir%system32WindowsPowerShellv1.0powershell.exe -noexit -command import-module ActiveDirectory

  • Anonymous
    September 26, 2013
    Bo, enable psremoting on the remote host first. PS C:>enable-psremoting -force

  • Anonymous
    February 02, 2014
    The comment has been removed

  • Anonymous
    May 12, 2014
    @JMorgan Just wanted to thank you for the tips and script.  Worked like a champ (though my desktops are taking way longer to load the module than I would like). Just a couple of notes:

  1.  I was able to get the GACUtil from the Visual Studio install under C:Program FilesMicrosoft SDKsWindowsv8.0Abin .  Keep in mind that this file is not supposed to be distributed per the licensing agreement so you can't give it out to others.
  2. I had to do a search under C:Windows to find the DLL and I found both x64 and x86, though they appear to be the same file. Thanks again!
  • Anonymous
    July 30, 2014
    You still need an active directory 2008 as the 2003 does not support this feature

  • Anonymous
    January 20, 2015
    How do it using powershell ? Navigate to Control Panel > Programs and Features > Turn Windows Features On or Off and select Active Directory Module for Windows PowerShell Activate feature Active Directory Module for Windows PowerShell programmatically ?

  • Anonymous
    February 12, 2015
    Hey All, I'm trying to install the software (Windows6.0-KB968934-x86) from the link at the top on Server 2008 R2 32 bit. I get error "The update does not apply to your system".  I also tried other 3 packages just in case but as expected they didn't work either. Any Ideas? Thanks In Advance,

  • Anonymous
    February 25, 2015
    1.Download and install Remote Server Administration Tools for Windows 7 (www.microsoft.com/.../details.aspx) •NOTE: Select either the x86 or x64 version, as appropriate for your Windows 7 workstation. •NOTE: The installer may seem inactive for some time. This is normal. 2.Once the installation is complete, navigate to the Control Panel and select Programs and Features, and click Remote Server Administration Tools. 3.Select AD DS and AD LDS Tools and then select Active Directory Module for Windows PowerShell. 4.Open a PowerShell prompt and type PS C:> Get-Module –ListAvailable. 5.To ensure the Active Directory Module is present, using PowerShell type PS C:> Import-Module ActiveDirectory. •NOTE: You will need to do this for every PowerShell session. 6.If you wish to have the Active Directory Module automatically loaded any time you run PowerShell, prepare a shortcut with the following content: %windir%system32WindowsPowerShellv1.0powershell.exe -noexit -command import-module ActiveDirectory 7.Open a new PowerShell session using the shortcut prepared above and run Get-Module.

  • Anonymous
    March 03, 2015
    The comment has been removed

  • Anonymous
    March 11, 2015
    Is there a way to get the members of a distribution group listed as output, via powershell or otherwise? Not the objectclass, GUID, SID etc, only user names.

  • Anonymous
    April 21, 2015
    drreid: I hate to tell you this, but this software only works for certain versions of Windows 7. If you get that message, your version of Windows 7 is not one of those. So the message that you received is in fact correct. Have a good day.