Obtaining user object information via Active Directory Users And Computers is fine for the one-time use, but it falls short for batch tasks. During this episode of TR Dojo, I’ll share three scripts make it easy to pull user information from Active Directory via PowerShell.
For those who prefer text to video, you can click the Transcript link that appears below the video player window. And to make it easier for you to try out and modify the PowerShell scripts I discuss in the video, here is the text for each one:
Changing an attribute for a group of users
Get-ADUser -Filter * -SearchBase "OU=Accounting,OU=UserAccounts,DC=YourDomain,DC=com" | Set-ADUser -Manager "John Doe"
Copying one user’s group memberships to a second user
Get-ADPrincipalGroupMembership -Identity JohnDoe | % {Add-ADPrincipalGroupMembership -Identity JaneDoe -MemberOf $_}
Pulling a list of user accounts with passwords that don’t expire
Search-ADAccount -PasswordNeverExpires | FT Name, ObjectClass, UserPrincipalName
For more PowerShell tips and tricks, check out the following resources from TechRepublic and around the Web:
- Two PowerShell scripts for retrieving user info from Active Directory
- 10 cool things you can do with Windows PowerShell
- Quickly find space-hogging files with PowerShell
- Get database properties using PowerShell in SQL Server 2008
- Three PowerShell queries to obtain critical system information
- Two Windows PowerShell tips for the administration ninja
- Windows PowerShell (Microsoft)
- Scripting with Windows PowerShell (Microsoft TechNet)
You can also sign up to receive the latest TR Dojo lessons through one or more of the following methods: