A follow on from the previous script, I had to then add some users to a distribution list. The following command was used:
get-user -organizationalUnit "domai.local/Company/State/OfficeLocation/Department/Team" | ` select UserPrincipalName | ` foreach { Add-DistributionGroupMember -identity "SA IP Agents" -member $_.UserPrincipalName }
Like the previous script, line 1 is getting users from he specified OU. In this operation, we really only need the User Principle Name. Line 3 iterates through the results, using the Add-DistributionGroupMember cmdlet to add the user.