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

About The Author

Leave a Comment

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

Scroll to Top