Add users to a distribution group based on Job title

by Jordan at 2013-03-13 07:25:49

Need a PowerShell script that will add users to a distribution group based on Job title.

What I have so far.

Add-DistributionGroupMember -Identity "Group name" -Job title "title name"
by DonJ at 2013-03-13 08:16:13
Yeah, but that command won’t actually work. The documentation for Add-DistributionGroupMember is at http://technet.microsoft.com/en-us/libr … 1%29.aspx; it does not have a "-job title" parameter.

You specify -Identity to tell it what group to modify, and -Member to specify the new members. For example, -Member (), and in the parentheses you’d put a command that retrieved the users you wanted.
by nate-n8 at 2013-03-13 10:46:00
might be easier if you create a dynamic list instead based off the job title.

Hi,

You can create a csv file of the users with specific job title, then use this csv file to update the distribution group members. Please follow the below script. Modify the bold italic part with your values

  • Get-User -ResultSize unlimited | Where-Object {$_.title -eq 'title name'} | Select-Object userprincipalname | Export-Csv c:\temp\Titleusers.csv
  • Import-Csv C:\temp\Titleusers.csv | ForEach-Object { Add-DistributionGroupMember -Identity DistributionGroupName -Member $_.userprincipalname}
Regards.