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.