파워셀로 o365 그룹생성시
1. Create and delete Distribution Groups
1.1 – Create a Distribution Group
PowerShell command Syntax
1 |
New-DistributionGroup -Name "<Distribution Group Name>" |
PowerShell command Example
1 |
New-DistributionGroup -Name "DL USA" |
1.2 – Create a Distribution Group + Details
PowerShell command Syntax
1 |
New-DistributionGroup -Name <DL name> -DisplayName <DL display name> -Alias <Alias> -PrimarySmtpAddress <Email Address> |
PowerShell command Example
1 |
New-DistributionGroup -Name DL-USA -DisplayName DL-USA -Alias DL-USA -PrimarySmtpAddress DL-USA@o365info.com |
1.3 – Delete (Remove) a Distribution Group
PowerShell command Syntax
1 |
Remove-DistributionGroup "<Distribution Group Name>" |
PowerShell command Example
1 |
Remove-DistributionGroup "DL USA" |
2. Manage Distribution Groups General Settings
2.1 – Add user to a Distribution Group
PowerShell command Syntax
1 |
Add-DistributionGroupMember "<Distribution Group Name>" -Member <Identity> -BypassSecurityGroupManagerCheck |
PowerShell command Example
1 |
Add-DistributionGroupMember -Identity DL-USA -Member John -BypassSecurityGroupManagerCheck |
2.2 – Setting Distribution Groups to accept Senders outside of my organization
PowerShell command Syntax
1 |
Set-DistributionGroup "<Distribution Group Name>" -RequireSenderAuthenticationEnabled $False |
PowerShell command Example
1 |
Set-DistributionGroup "DL USA" -RequireSenderAuthenticationEnabled $False |
2.3 – Adding Distribution Group owner
PowerShell command Syntax
1 |
Set-DistributionGroup -Identity "<Distribution Group Name>" –ManagedBy <Identity> -BypassSecurityGroupManagerCheck |
PowerShell command Example
1 |
Set-DistributionGroup -Identity "DL-USA" -ManagedBy John -BypassSecurityGroupManagerCheck |
2.4 – Set a specific user as owner of all Office 365 (Bulk Mode)
PowerShell command Syntax
1 |
Get-DistributionGroup |Set-DistributionGroup -ManagedBy <Identity> –BypassSecurityGroupManagerCheck |
PowerShell command Example
1 |
Get-DistributionGroup | Set-DistributionGroup -ManagedBy “John” –BypassSecurityGroupManagerCheck |
2.5 – Add an Email Alias to Distribution group
PowerShell command Syntax
1 |
Set-DistributionGroup "<Distribution Group Name>" -EmailAddresses SMTP:<Primary Email>,<Alias Email> |
PowerShell command Example
1 |
Set-DistributionGroup "DL-USA" –EmailAddresses SMTP:DL-USA@o365info.com,dev@o365info.com |
2.6 – Hide Distribution group from GAL
PowerShell command Syntax
1 |
Set-DistributionGroup "<Distribution Group Name>" -HiddenFromAddressListsEnabled $True |
PowerShell command Example
1 |
Set-DistributionGroup "DL 01" -HiddenFromAddressListsEnabled $True |
2.7 – Create new Security Distribution Group
PowerShell command Syntax
1 |
New-DistributionGroup -Name <Distribution Group Name> -Type Security |
PowerShell command Example
1 |
New-DistributionGroup -Name "All Users" -Type Security |
Adjustments & Customizations: Set Email Address for the Distribution Group
PowerShell command Example
1 |
New-DistributionGroup -Name "All Users" -Type Security -PrimarySmtpAddress AllUsers@o365info.com |
2.8 – Import Distribution Group members from a CSV File
PowerShell command Syntax
1 |
Import-CSV <path> | ForEach {Add-DistributionGroupMember -Identity <Distribution Group Name> -Member $_.members} |
PowerShell command Example
1 |
Import-CSV C:\Temp\DL-Users.csv | ForEach {Add-DistributionGroupMember -Identity DL-USA -Member $_.members} |
2.9 – Create Bulk Distribution Groups from a CSV File
PowerShell command Syntax
1 |
Import-CSV | ForEach {New-DistributionGroup -Name $_.name -Type $_.Type} |
PowerShell command Example
1 |
Import-CSV C:\Temp\DL-Group.csv | ForEach {New-DistributionGroup -Name $_.name -Type $_.Type} |
2.10 – Add recipient to multiple distribution groups
PowerShell command Syntax
1 |
$Array = "<DL name>","<DL name>","<DL name>" ForEach ($item in $Array) { Add-DistributionGroupMember -Identity $item –Member <Identity> –BypassSecurityGroupManagerCheck } |
PowerShell command Example
1 |
$Array = "DL 01","DL 03","DL 03" ForEach ($item in $Array) { Add-DistributionGroupMember -Identity $item –Member John –BypassSecurityGroupManagerCheck } |
2.11 – Enable external sender to send email to the distribution group (Bulk Mode)
PowerShell command Example
1 |
Get-DistributionGroup | Set-DistributionGroup -RequireSenderAuthenticationEnabled $False |
Prevent external sender to send email to the distribution group (Bulk Mode)
PowerShell command Example
1 |
Get-DistributionGroup | Set-DistributionGroup -RequireSenderAuthenticationEnabled $True |
3. Assign Permissions to Distribution Groups
3.1 – Assign “Send As” Permissions to Distribution Group
PowerShell command Syntax
1 |
Add-RecipientPermission "<Distribution Group Name>" -Trustee <Identity> -AccessRights SendAs -Confirm:$False |
PowerShell command Example
1 |
Add-RecipientPermission DL-USA -Trustee John -AccessRights SendAs -Confirm:$False |
3.1 – Assign “Full Access” permissions to Distribution Group + AutoMapping
PowerShell command Syntax
1 |
$DL = Get-DistributionGroupMember <Distribution Group Name> | Select-Object -ExpandProperty Name ForEach ($Member in $DL) {Add-MailboxPermission -Identity <Identity> -User $Member -AccessRights ‘FullAccess’ -InheritanceType all} |
PowerShell command Example
1 |
$DL = Get-DistributionGroupMember "DL 01"| Select-Object -ExpandProperty Name ForEach ($Member in $DL) {Add-MailboxPermission -Identity "FL1 Room1" -User $Member -AccessRights ‘FullAccess’ -InheritanceType all} |
Additional reading
4. Manage Dynamic Distribution Groups
4.1 – Create Dynamic Distribution Group for all Office 365 users
PowerShell command Syntax
1 |
New-DynamicDistributionGroup -Name "<Distribution Group Name>" –RecipientFilter { (RecipientType -eq 'UserMailbox') } |
PowerShell command Example
1 |
New-DynamicDistributionGroup -Name "DL USA" –RecipientFilter { (RecipientType -eq 'UserMailbox') } |
4.2 – Create Dynamic Distribution Group for user from specific Office
PowerShell command Syntax
1 |
New-DynamicDistributionGroup -Name "<Distribution Group Name>" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Department –like <'Department Name'>)} |
PowerShell command Example
1 |
New-DynamicDistributionGroup -Name "Marketing" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Department -like 'NY')} |
4.3 – Create Dynamic Distribution Group for all managers
PowerShell command Syntax
1 |
New-DynamicDistributionGroup -Name "<Distribution Group Name>" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Title –like <'Title1*'> -or Title -like <'Title2*'>)} |
PowerShell command Example
1 |
New-DynamicDistributionGroup -Name "Org Managers" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Title -like 'Director*' -or Title -like 'Manager*' )} |
5. Display Information about Distribution Groups
5.1 – Display Distribution Group Members
PowerShell command Syntax
1 |
Get-DistributionGroupMember "<Dynamic Group Name>" |
PowerShell command Example
1 |
Get-DistributionGroupMember "DL USA" |
5.2 – Display members of Dynamic Distribution Group
PowerShell command Syntax
1
2 |
$DDG = Get-DynamicDistributionGroup "<Dynamic Group Name>"
Get-Recipient -RecipientPreviewFilter $DDG.RecipientFilter | FT Alias |
PowerShell command Example
1
2 |
$DDG = Get-DynamicDistributionGroup "DL USA"
Get-Recipient -RecipientPreviewFilter $DDG.RecipientFilter | FT Alias |
5.1 – Display list of Distribution Groups
PowerShell command Syntax
1 |
Get-DistributionGroup |
5.1 – Display list of Distribution Groups with specific Email Domain name suffix
PowerShell command Syntax
1 |
Get-DistributionGroup | Where {$_.emailaddresses –like <"*Domain Name*">} | FT -Property Name,Alias,EmailAddresses -Autosize |
PowerShell command Example
1 |
Get-DistributionGroup | Where {$_.emailaddresses –like "*o365info.com*"} | FT -Property Name,Alias,EmailAddresses -Autosize |
5.1 – Display information about Distribution Group that was updated before a specific date
PowerShell command Syntax
1 |
Get-DistributionGroup | Where{$_.WhenChanged -gt ((Get-Date).AddMonths(- <Number of Month>))} |
PowerShell command Example
1 |
Get-DistributionGroup | Where{$_.WhenChanged -gt ((Get-Date).AddMonths(-1))} |
6. Download PowerShell Distribution Groups menu script
참고사이트 :
http://o365info.com/manage-distribution-groups-by-using/
https://technet.microsoft.com/library/mt219359(v=exchg.160).aspx