Active Directory PowerShell Module
Hello,
A quick follow up from an old post, there some bonus feature with the Active Directory module. This module is not as efficient as the ADSI objects shown in the post but hereunder some example of bonus features.
Active Directory PowerShell Module Prerequisites
This module has three requirements :
- Windows Server 2008R2 or higher as Domain Controller
- Windows Server 2008R2 or Windows 7 or higher as a PowerShell host
- Remote Server Administration Tools
You can also install Active Directory Management Gateway Services on older version of Windows Server that will provide the same features as Active Directory Web Services.
Active Directory PSDrive
When the module is imported, it will create you a PowerShell drive that will allow you to browse the domain just like you do with your logical drive or your local registry hives:
Get-PSDrive Import-Module ActiveDirectory Get-PSDrive Set-Location ad:
Active Directory ACL
You can see the ACL with Get-Acl:
Get-Acl '.DC=D2K12R2,DC=local' | Select-Object -ExpandProperty Access | Out-GridView
List Users in a Organizational Unit
You can list the users in an OU with a standard Get-ChildItem:
Get-ChildItem -Path 'OU=Users,OU=Star Wars,OU=Production,DC=D2K12R2,DC=local'
Note: The users came from this post:
List Sites
You can list sites with a Get-ChildItem like for users, you just need to change the path. Indeed, the Active Directory sites are stored in the partition configuration:
Get-ChildItem -Path 'CN=Sites,CN=Configuration,DC=D2K12R2,DC=local'
Move Users
You move move users from an organizational unit to another one with:
Move-Item -Path 'CN=Junk7,OU=Test,DC=D2K12R2,DC=local' -Destination 'OU=Trash,OU=Test,DC=D2K12R2,DC=local'
Note: This will work with computers and groups too.
Delete Users
You can delete a user just like a file on your disk:
Remove-Item -Path 'CN=Junk7,OU=Trash,OU=Test,DC=D2K12R2,DC=local'
This will work on other types of objects too.
Other cmdlets
There is a lot of cmdlets that you can use, actually, there is 147 cmdlets in this module in Windows Server 2012R2. Each new version of Windows Server brings some new cmdlets, hereunder a list of them from a Windows Server 2012R2 server:
Pingback: Active Directory Password not Required - It for DummiesIt for Dummies
Pingback: Renew Active Directory User Password Without Knowing It - It for DummiesIt for Dummies