Get The Count of the Number of Users in an AD Group
I was challenged at work today to determine the number of users in an Active Directory group. I figured the best way was to break out PowerShell and see what I could find (I'm sorry but I'm learning PowerShell so things are going to be very PowerShell centered for a while :-)). I found that in the ActiveDirectory PowerShell module (see http://www.mikepfeiffer.net/2010/01/how-to-install-the-active-directory-module-for-windows-powershell/ for instructions on how to install this) the Get-ADUser cmdlet works really well for running basic searches in AD.
The first step is to import the module:
Then you can run a search on the user information you want for example this returns the count of all users in a group:
This returns the count of all group members who have an expiration date:
The cool things about the get-aduser cmdlet is that it automatically pulls common fields (username, surname, etc.) but by adding items to the -property field it will return additional items. If there are other searches you find useful please add them to the comments below.
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows