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. Anything from desktops to servers with a side of mountain biking and skiing. Life is good!

Related Articles

Leave a Reply

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

Back to top button