Saturday, May 15, 2010

Dynamic Distribution Groups in bulk using powershell

Here is a small script written by me for creating  Dynamic Distribution Groups in bulk using powershell

#import csv file (script.ps1  csv file)

$data = import-csv $args[0]

#create a vriable for holding condition

 $str = new-object System.Text.Stringbuilder

foreach ($i in $data)

{

# read filter (office value from csv file)

$dgp = $i.filter

$str = {(office -eq $dgp)}

New-DynamicDistributionGroup -Name $i.initials -OrganizationalUnit $i.ou -RecipientFilter $str -RecipientContainer $i.domain

}

In the same way you can  create multiple conditions & create dynamic distribution groups based on various AD attributes.

No comments:

Post a Comment