通过AzureAD中的Powershell创建统一的动态成员资格Office 365组

通过AzureAD中的Powershell创建统一的动态成员资格Office 365组,powershell,azure-active-directory,office365,azure-ad-powershell-v2,Powershell,Azure Active Directory,Office365,Azure Ad Powershell V2,在Azure的GUI中,执行此操作非常简单—您只需创建一个新的office 365组并设置动态规则,但通过powershell执行此操作似乎很困难—我能得到的最接近的是使用以下powershell行。组类型部分似乎出错了。我似乎无法用这两种类型创建一个组,我猜我只是没有正确地格式化它。我正在使用版本2.0.2.85的AzureADPreview模块,因为普通的AzureAD模块根本不适用于此 New-AzureADMSGroup -DisplayName "name" -Description

在Azure的GUI中,执行此操作非常简单—您只需创建一个新的office 365组并设置动态规则,但通过powershell执行此操作似乎很困难—我能得到的最接近的是使用以下powershell行。组类型部分似乎出错了。我似乎无法用这两种类型创建一个组,我猜我只是没有正确地格式化它。我正在使用版本2.0.2.85的AzureADPreview模块,因为普通的AzureAD模块根本不适用于此

New-AzureADMSGroup -DisplayName "name" -Description "description" -MailEnabled $True -MailNickName "MailName" -SecurityEnabled $True -GroupTypes 'Unified, DynamicMembership' -MembershipRule '(user.userPrincipalName -contains "somafeasokdfalksjfjlkads")' -MembershipRuleProcessingState $true
告诉我错误

Code: Request_BadRequest
Message: Invalid value specified for property 'groupTypes' of resource 'Group'.


要点是我正试图找到一种powershell方法来获得第二张照片所示的Azure群。Ie既是动态的又是统一的。

我想出了一个办法,你可以创建一个统一的团队,然后使用微软发布的脚本

我不得不修改它以使其工作,但基本上我运行了以下程序

$knowngoodgroup = 'INSERTGUID'
$BadGroup       = 'INSERTGUID'
$memberRule     = 'INSERTMEMBERRULE'

[System.Collections.ArrayList]$groupTypes = (Get-AzureAdMsGroup -Id $knowngoodgroup).GroupTypes
Set-AzureAdMsGroup -Id $BadGroup -GroupTypes $groupTypes.ToArray() -MembershipRuleProcessingState "On" -MembershipRule $memberrule

我猜他们将来会解决这个问题。

根据我写它的方式,目前可能不支持它。我还收到以下错误。代码:Request\u BadRequest Message:该服务当前不支持对已启用邮件的组进行写入。请确保邮件启用属性未设置,并且安全启用属性已设置。