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