Skip to main content
  1. Blog Posts/

Finding users in AD and adding to distribution group

·82 words·1 min

I had a scenario in which a group of users needed to be added to a distribution group hosted on Exchange online.

So I thought Id made a little script which pulls users from the local Active Directory; checks them against the distribution group and if they are not present, adds them.

You may want to customize the “-SearchBase” parameter depending on your requirements. You could also pipe the ADUsers with “where” to get users with a specific property such as location.

Joshua Robbins
Author
Joshua Robbins
I write about the things I’m building, learning, breaking and fixing across Computer Science and Cyber Security.