Disclaimer: We hope that the information on these pages is valuable to you.
Your use of the information contained in these pages, however, is at your sole risk.
All information on these pages is provided "as -is", without any warranty, whether express or implied,
of its accuracy, completeness, fitness for a particular purpose, title or non-infringement,
and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by site owners or operators.
Further, the site owners and operators shall not be liable for any damages you may sustain by using this information,
whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.
Warning: main(/home/prosphot/public_html/smog/track/write_logs.php) [function.main]: failed to open stream: No such file or directory in /home/prosphot/public_html/blog/skins/leaf/footer.php on line 3
Warning: main(/home/prosphot/public_html/smog/track/write_logs.php) [function.main]: failed to open stream: No such file or directory in /home/prosphot/public_html/blog/skins/leaf/footer.php on line 3
Warning: main() [function.include]: Failed opening '/home/prosphot/public_html/smog/track/write_logs.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/prosphot/public_html/blog/skins/leaf/footer.php on line 3
Tue 07.29.08: Dynamic - non dynamic distribution list
We have a distribution list that needs to have specific members in it, but we don't want to update it all the time. This distribution list needs to be a little more selective than we can get a dynamic distribution list to be. So we created a script that blows away the distribution lists membership, and then re-adds it using powershell script.Here is the code:
$DLIST = "FYI All"
# Delete Distribution List Members
Get-DistributionGroupMember -Identity $DLIST | Remove-DistributionGroupMember -Identity $DLIST -confirm:$false
# Add Mailbox Users
get-mailbox -OrganizationalUnit "[OU GOES HERE]" | where {$_.OrganizationalUnit -eq "[OU GOES HERE]"} | Add-DistributionGroupMember -Identity $DLIST
# Add Email Enabled Users
$a= get-mailuser -OrganizationalUnit "[OU GOES HERE]"
foreach ($item in $a) {
Add-DistributionGroupMember -Identity $DLIST -Member $item.UserPrincipalName
}
-------------------------------------------------
The main problem we ran into was that it would also include all of the users in the the sub OUs (contractors, and terminations). So this script only adds thoes in the parent OU, not the sub OUs. We also needed to add the second part to add users that are mail users, but don't have mailboxes.
Item Rating Information....
Total Votes: 1 - Rating: 5.00