【问题标题】:How to create a Dynamic Office 365 Group如何创建动态 Office 365 组
【发布时间】:2019-09-19 06:00:35
【问题描述】:

我是 Exchange Online 和 Azure 的新手,但有人问我是否可以使用 New-UnifiedGroup 和 Set-UnifiedGroup cmdlet 在 Exchange Online 中创建 O365 组。然后他们希望能够根据某些标准使这些群体充满活力。这是否可能,或者我是否完全跳过 Exchange Online,并在 Azure 中使用 New-AzureADMSGroup cmdlet 创建动态组。

感谢任何帮助。 谢谢。

【问题讨论】:

  • 你有什么更新吗?这有帮助吗?
  • 是的,我相信我终于弄明白了。您需要同时使用 Exchange Online、(New-UnifiedGroup/Set-UnifiedGroup) cmdlet,还需要连接到 AzureAD 并使用 Set-AzureADMSGroup cmdlet。我将在今天晚些时候发布代码,只是微调它。

标签: azure powershell exchange-server


【解决方案1】:

是的,您可以使用 AzureAD PowerShell cmdlet New-AzureADMSGroup 创建一个 Office 365 组,并且您需要先安装 AzureAD 模块。

例如,此命令使用以下规则创建一个新的动态组:

user.department - 包含“营销”

双引号替换为单引号。

处理状态为开启。这意味着目录中的所有用户 符合规则的将作为成员添加到组中。任何用户 不符合条件的将从组中删除。

New-AzureADMSGroup -DisplayName "Dynamic Group 01" -Description "Dynamic group created from PS" -MailEnabled $False -MailNickName "group" -SecurityEnabled $True -GroupTypes "DynamicMembership" -MembershipRule "(user.department -contains ""Marketing"")" -MembershipRuleProcessingState "On"

更多参考:https://techcommunity.microsoft.com/t5/Azure-Active-Directory-Identity/New-enhancements-to-the-AzureAD-PowerShell-2-0-preview-Manage/ba-p/245153

https://blog.hubfly.com/office-365/useful-powershell-cmdlets-to-administer-office-365-groups-part-1

【讨论】:

  • 这将创建一个动态的 AzureAD 安全组。我想要的是一个动态的 Office365 组。
【解决方案2】:

好的,这就是我们想出的解决方案。

需要 AzureADPreview 模块,当前版本为 2.0.2.17

AzureAD 模块无法工作,因为它缺少组成员身份所需的参数。

需要连接到 AzureAD 和 Exchange Online。

您连接的帐户需要是 Exchange Online 中的 Exchange 管理员和 AzureAD 中的用户管理员。 在我们的示例中,我们需要一个动态的 Office 组,以及基于 extensionattribute12 的 membersRule。

#***********************************************************************
$ADUser = "samAccountName@yourdomain"
$ADPassword = 'the password'
$ADPwd = $ADPassword | ConvertTo-SecureString -AsPlainText -Force
$UserCredential = new-object system.management.automation.pscredential $ADuser, $ADPwd
#***********************************************************************
"Connect AzureAD"
Connect-AzureAD -Credential $UserCredential

"Connect to Exchange Online"
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking

#######################################
function ConvertStaticGroupToDynamic
{
     Param([string]$groupId, [string]$dynamicMembershipRule)
     $dynamicGroupTypeString = "DynamicMembership"
     #existing group types
     [System.Collections.ArrayList]$groupTypes = (Get-AzureAdMsGroup -Id $groupId).GroupTypes

     if($groupTypes -ne $null -and $groupTypes.Contains($dynamicGroupTypeString))
     {
         throw "This group is already a dynamic group. Aborting conversion.";
     }
     #add the dynamic group type to existing types
     $groupTypes.Add($dynamicGroupTypeString)

     #modify the group properties to make it a static group: i) change GroupTypes to add the dynamic type, ii) start execution of the rule, iii) set the rule
     Set-AzureAdMsGroup -Id $groupId -GroupTypes $groupTypes.ToArray() -MembershipRuleProcessingState "On" -MembershipRule $dynamicMembershipRule
}
#######################################
$ExtAtt12 = "Marketing"
$NewGroupName = "O365-OfficeGroupTest"
"[$NewGroupName] create group"
New-UnifiedGroup -DisplayName $NewGroupName
Set-UnifiedGroup $NewGroupName -UnifiedGroupWelcomeMessageEnabled:$false
$ID = (Get-UnifiedGroup $NewGroupName).ExternalDirectoryObjectId
sleep 15 # Allow time for Exchange Online to Sync with AzureAD
ConvertStaticGroupToDynamic -groupId $ID -dynamicMembershipRule "(User.extensionattribute12 -eq ""$ExtAtt12"")"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-30
    • 2018-01-30
    • 1970-01-01
    • 2016-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多