79086672

Date: 2024-10-14 15:01:47
Score: 3
Natty:
Report link

I'm not very experienced in powershell so just looking for articles here to get something done.

Is there a way to use similar like "Get-ADPrincipalGroupMembership -Identity $user | Select -ExpandProperty Name | Select-String -Pattern 'Part of Group Name' " but with function Add-ADPrincipalGroupMembership or ADD-ADGroupMember if I don't want to enter the specific name of the group but just part of it?

I have this

Get-ADPrincipalGroupMembership $Users | Where-Object {$_.Name -like "SAP-GEN-P-DP4*"}|

Followed by this but it is of course incorrect.

ForEach-Object {Add-ADPrincipalGroupMembership "SAP-GEN-P-DQ4*" -Members $users}

As the name of those groups are very long and there are more than 30 of those groups I would like to assign users who have "SAP-GEN-P-DP4*" also groups with "SAP-GEN-P-DQ4*"

Thank you for any help

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (1): any help
  • Blacklisted phrase (1): Is there a way
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Michal Brom