Leveraging Powershell to manage Active Directory

      No Comments on Leveraging Powershell to manage Active Directory

As a sysadmin certain tasks can really bug you because they are so frequent and repetitive! Being from a lazy nature I personally like to automate as much as possible 🙂

Here are some of the AD queries I usually rely on to make my life easier, will add more and more to this post as they come to mind.
Before we start just wanted to give a quick intro to arrays which we will use a lot HERE.

Search for list of groups and display disabled account members. For enabled accounts change $false to $true. I’m using a static group but this would be more useful using CSV file also mentioned in the Powershell Arrays post.

$groups = @("group1","group2","group3")
foreach ($group in $groups) {
Get-ADGroupMember -Identity $group | where {Get-aduser -Filter {enabled -eq $false}}
}

Working CSV files is great (faster and safer if you ask me) but how about getting live data from AD? No problem!

Get all AD groups which name starts with “blab”.
Get-ADGroup -Filter {name -like "blab*"} -Properties * | Select Name,Description

Leave a Reply

Your email address will not be published. Required fields are marked *