azure - 如何创建动态 Office 365 组
问题描述
我是 Exchange Online 和 Azure 的新手,但有人问我是否可以使用 New-UnifiedGroup 和 Set-UnifiedGroup cmdlet 在 Exchange Online 中创建 O365 组。然后他们希望能够根据某些标准使这些群体充满活力。这是否可能,或者我是否完全跳过 Exchange Online,并在 Azure 中使用 New-AzureADMSGroup cmdlet 创建一个动态组。
任何帮助表示赞赏。谢谢。
解决方案
好的,这就是我们提出的解决方案。
需要 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"")"
推荐阅读
- reactjs - 我创建了一个反应项目并开始研究路由,路由工作正常但导航栏无法正常工作
- postgresql - Postgres中下划线的排序问题
- php - 从数据库中删除记录的ajax不会在laravel中触发重定向
- netsuite - 在 Netsuite 2.0 中加载时如何将额外的过滤器和列添加到现有的已保存搜索中
- php - 如何将函数作为参数传递php类
- bash - 自动保存电子邮件附件以映射到 qmail 和 Reformime
- html - Haskell Yesod 网络表单到 Sqlite3
- c# - 如何列出使用 MEF2 实现接口的所有类型?
- kubernetes - 迁移到 Kubernetes 1.16 所需的更改
- tomcat8 - 当服务器类型 = 定期时,LifecycleListener 在服务器启动后未侦听