As title says I need to get a specific part of a group name of group of users.
Yup, Get-ADPrincipalGroupMembership
allows to get user's groups. But it returns all user's groups (while I would like to get an exact one) and, as I understood, only for a exact user.
So I have three OUs. Each OU has users. Each user is member of a few groups, but I need to get a group(s) with a standard name per user. And standard name is department - X
, where X part is specific for each user. So in a result I want to get a table, where will be Name, SamAccountName and X part of the group(s).
Hence, I need:
- Get list of users and it's groups from exact OU;
- From list of all users and it's groups I need to get group that has standard name per user. Standard name is
department - X
, where X part is specific for each user, and one user could has more than one group with the standard name; - Per user I need to get X part from group(s) with the standard name.