Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions #6

Closed
FullDad opened this issue Jan 28, 2022 · 2 comments
Closed

Exceptions #6

FullDad opened this issue Jan 28, 2022 · 2 comments

Comments

@FullDad
Copy link

FullDad commented Jan 28, 2022

This is going to be weird question, but is there a way for me to simply exclude 2 groups?

I have 2 groups that are teams groups and as soon as people get removed, it dings everyone in my company.

I have the object ID of the 2 groups, is there a simple line of code i could add to exclude them?

Really appreciate your help. I've been trying for hours. lol

@michevnew
Copy link
Owner

Which script are we talking about here, the Remove_User_All_Groups.ps1 one? You can add an exception within the foreach loop (line 130), something like:

foreach ($Group in $Groups) {
if ($Group.DisplayName -eq "Team1") { continue }
...
}

It's better to use a unique-valued identifier, such as the ExternalDirectoryObjectId, but DisplayName should also do. Here's example with the former:

foreach ($Group in $Groups) {
if ($Group.ExternalDirectoryObjectId -eq "GUID") { continue }
...
}

@FullDad
Copy link
Author

FullDad commented Jan 28, 2022

I can't believe how fast you got back to me. Literally spent the last 2 hours pulling people in who know a little about the code. LOL. That fixed it!!!!! Thank you so much!!!! This is going to make my life a lot easier!

@FullDad FullDad closed this as completed Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants