Adding Users to O365 Distribution List
A script I recently used to add members to an office 365 distribution group using a remote exchange session in a hybrid setup (covered at the end).
1 2 3 4 5 |
[cc lang="powershell"]$SourceFile = "" Import-CSV $SourceFile | ForEach ` {Add-DistributionGroupMember -Identity "Group Name" -Member $_.UPN Write-Host -ForegroundColor Green "Processed the record for $($_.UPN)" }[/cc] |
CSV file contains UPNs of all users to be added. I also found it useful to see who had permissions to send to this group using
1 |
[cc lang="powershell"](Get-DistributionGroup -Identity "Group Name").AcceptMessagesOnlyFrom | ForEach {Get-User -Identity $_}[/cc] |
…