It’s been a while since my last post, but, I have a business need to create a clone of an AD user members security groups to a couple of new hires. I have the code written that I need to do this, however, there are multiple AD security groups that can NOT be added and I need them excluded in the script. I am using where {$_ -notlike as my filtering system but from trial and error, it appears that only works to filter out ONE AD security group and not multiple.
Does anyone have any suggestions? I am still relatively new to powershell. I’ll need help as soon possible, thanks!
Code is below (names modified for confidentiality):
This is the code that works but does NOT have multiple exclusions:
Olaf–I tried your suggestion and it doesn’t seem to work as intended. After running it in my environment, all it does it copy the AD security groups completely, instead of making any exclusions in the suggested operators.