Advertisement
sheldonalman

Exchange 2010 Distribution Group Convertor

Jul 6th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Convert a dynamic distribution group to a regular distribution group in Exchange 2010
  2. #Sheldon Alman - sheldonalman at gmail.com
  3.  
  4. $employees = Get-DynamicDistributionGroup "(dynamic group)" #This is the dynamic group to be read from
  5. $groupName = Get-distributiongroup "(regular group name)" -erroraction 'silentlycontinue' #This is the group to be modified. Continues if there are any errors encountered.
  6.  
  7. #if the group exists, remove it and re-create it.  If it doesn't exist, create it.
  8. if ( $groupname )
  9. {
  10.     remove-distributiongroup "(regular group)" -Confirm:$false #disables confirmation of group removal.
  11.     new-distributiongroup "(regular group)"
  12.     set-distributiongroup "Employees" -customattribute11 "(whatever attribute you use to populate the group)"
  13. }
  14. else
  15. {
  16.     new-distributiongroup "(regular group)"
  17.     set-distributiongroup "(regular group)" -customattribute11 "(whatever attribute you use to populate the group)"
  18. }
  19. Get-Recipient -RecipientPreviewFilter $employees.RecipientFilter | export-csv C:\filename.csv #prints pertinent information about members of the group and exports it to csv
  20.  
  21. import-csv C:\filename.csv | foreach { Add-DistributionGroupMember "(regular group)" -member $_.name }
  22. Remove-item C:\filename.csv -Confirm:$false #remove csv file if necessary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement