一、创建

1.静态组
        New-DistributionGroup  -Name "PingTai"   -Type Distribution
2.动态组
        New-DynamicDistributionGroup   -Name "group" -RecipientContainer "corp.homelink.com.cn/链家网/CFO线/"  -ConditionalCustomAttribute1  "经纪人"  -IncludedRecipients MailboxUsers
3.批量创建动态组
        import-csv C:\Users\fanyunxiao\批量新建动态邮件组.csv  | foreach {New-DynamicDistributionGroup -Name  $_.name  -RecipientContainer  $_.recipientContainer   -ConditionalCustomAttribute1   $_.ConditionalCustomAttribute1  -IncludedRecipients  mailboxusers}

二、添加人员

1.静态组

import-csv C:\Users\fanyunxiao\批量添加静态组成员.csv | foreach {Add-DistributionGroupMember "group0101" -Member $_.mail}

三、查询动态组人员

Get-Recipient -RecipientPreviewFilter (Get-DynamicDistributionGroup -Identity [email protected]).LdapRecipientFilter -OrganizationalUnit (Get-DynamicDistributionGroup -Identity [email protected]).RecipientContainer -ResultSize unlimited

四、查询静态组人员

Get-ADGroupMember -Identity 'bod' -Recursive | Select-Object Name,SamAccountName | Export-Csv -Path 'C:\Users\fanyunxiao\user.csv' -NoTypeInformation -Encoding Unicode