This script will add a list of users in a text file to Distribution group and output the results to a log file.
Import-Module ActiveDirectory ## Use AD Snapin
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin ## Use Exchange 2007 Snapin
$AdminSessionADSettings.ViewEntireForest = $true ##Search Entire Forest
Get-Content ‘C:\Userlist.txt’ | %{
$User = $_
Try {
Add-DistributionGroupMember ‘GroupName’ -Member $User -EA STOP
}
Catch{
Echo $User $_.exception.Message
}
} | Out-File C:\scriptlog.txt
![Share on Facebook Facebook](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/facebook.png)
![Share on Twitter twitter](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/twitter.png)
![Share on Google+ google_plus](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/google_plus.png)
![Share on Linkedin linkedin](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/linkedin.png)
![feather](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/icon.png)