FeaturedMicrosoftTools

PowerShell | Find Users matching partial group name by employeeType

I needed a way to find out if any of our staff employeeType was part of incorrect distribution lists. Example: Classified staff shouldn’t be part of any distribution lists that contains “Licensed”.

Get-ADGroup -Filter {name -like "*Classified*"} | Get-ADGroupMember | Get-ADUser -Properties "*" |  Select-Object -Property samAccountName, employeeType

Here is the output:

If you wanted to export this to a csv just add on “| Export-Csv C:\” to the end so it would look like this

Get-ADGroup -Filter {name -like "*Classified*"} | Get-ADGroupMember | Get-ADUser -Properties "*" |  Select-Object -Property samAccountName, employeeType | Export-Csv C:\temp\employee_type.csv

Show More

Cory Fiala

Technology and outdoor enthusiast. Currently the sole systems administrator for a local K-12 school district with 800+ staff and 5,500+ students. I support windows servers (2012R2-2022), Linux systems (FreeBSD and Ubuntu), along with vSphere (4 node cluster). Total is almost 60 virtual machines and 8 physical servers. This doesn't include my personal homelab.

Related Articles

Leave a Reply

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

Back to top button