SOLVED

Dynamic Office 365 groups

%3CLINGO-SUB%20id%3D%22lingo-sub-5937%22%20slang%3D%22en-US%22%3EDynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-5937%22%20slang%3D%22en-US%22%3E%3CP%3EAny%20chance%20for%20dynamic%20Office%20365%20groups%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet's%20say%2C%20a%20new%20employee%20is%20hired%20for%20an%20organization.%20This%20person%20should%20be%20added%20automatically%20to%20this%20organization's%20Office%20365%20group%20to%20enable%20her%2Fhim%20to%20join%20the%20organization's%20team%20work%2C%20calendars%2C%20etc.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-5937%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%20Groups%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-145065%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-145065%22%20slang%3D%22en-US%22%3EI've%20tested%20this%20in%20a%20UAT%20Tenant%20and%20it's%20worked%20successfully.%20Cheers!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-143982%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-143982%22%20slang%3D%22en-US%22%3E%3CP%3EAlexander%20it%20works%20fine%20but%20make%20sure%20you%20read%20this%20article%20if%20you%20want%20to%20convert%20an%20Office%20365%20group%20from%20static%20to%20dynamic%20membership%20(you'll%20need%20to%20run%20a%20PowerShell%20cmdlets.%20Membership%20refreshes%20on%20a%20regular%20basis.%20try%20it%20out!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-143749%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-143749%22%20slang%3D%22en-US%22%3EHas%20anyone%20tried%20this%20specifically%20for%20Office%20365%20groups%3F%20I%20only%20have%20the%20option%20under%20newly%20created%20security%20groups%2C%20and%20only%20when%20they%20are%20created.%20Does%20the%20dynamic%20rule%20run%20on%20a%20schedule%2C%20or%20triggered%20somehow%20for%20a%20new%20user%3F%20Because%20from%20what%20I%20can%20see%20it's%20only%20done%20upon%20group%20creation.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-124061%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-124061%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Jared%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20If%20you%20work%20in%20the%20public%20education%20sector%2C%20talk%20to%20your%20Microsoft%20Licensing%20representative.%20There%20are%20other%20licensing%20options%20available%20to%20you%20that%20may%20allow%20you%20to%20use%20Dynamic%20Groups%20without%20having%20Azure%20Premium.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-58658%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-58658%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20not%20a%20great%20coder%20or%20scripter%20but%20I%20was%20able%20to%20come%20up%20with%20the%20following%20solution.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20created%20a%20powershell%20script%20that%20iterates%20through%20the%20AD%20structure%20automatically%20adding%20users%20to%20the%20Office%20365%20group%20based%20off%20of%20job%20titles.%20%26nbsp%3BI%20have%20this%20scheduled%20in%20task%20manager%20on%20our%20DC%20that%20hosts%20the%20AAD%20Connect%20software%20to%20run%20once%20a%20day%20adding%20and%20removing%20users%20from%20the%20Office%20365%20Group.%20%26nbsp%3BThe%20criteria%20can%20be%20changed%20to%20look%20at%20any%20field%20in%20the%20AD%20structure.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23Sets%20up%20the%20powershell%20environment%20retrieving%20an%26nbsp%3Bencrypted%20password%20from%20a%20text%20file%20decrypting%20it%20and%20storing%20the%20password%20in%20the%20%24O365credential%20variable%3C%2FP%3E%3CP%3E%24pwdloc%3DJoin-Path%20(Split-Path%20%24profile)%20creds.txt%3CBR%20%2F%3E%24O365password%20%3D%20gc%20%24pwdloc%3CBR%20%2F%3E%24o365password%20%3D%20ConvertTo-SecureString%20%24O365password%20-Force%3CBR%20%2F%3Eimport-module%20msonline%3CBR%20%2F%3E%24O365username%20%3D%20'%3COFFICE%20365%3D%22%22%20username%3D%22%22%3E'%3CBR%20%2F%3E%24O365credential%20%3D%20New-Object%20System.Management.Automation.PSCredential%20-ArgumentList%20%24O365username%2C%24O365password%3CBR%20%2F%3E%24sessionProxy%20%3D%20New-PSSessionOption%20-ProxyAccessType%20IEConfig%20-ea%20stop%3CBR%20%2F%3E%24Session%20%3D%20New-PSSession%20-ConfigurationName%20Microsoft.Exchange%20-ConnectionUri%20%3CA%20href%3D%22https%3A%2F%2Fps.outlook.com%2Fpowershell%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fps.outlook.com%2Fpowershell%2F%3C%2FA%3E%20-Credential%20%24O365credential%20-Authentication%20Basic%20-AllowRedirection%20-ea%20stop%3CBR%20%2F%3EImport-PSSession%20%24Session%20-AllowClobber%20-DisableNameChecking%20-ea%20stop%3CBR%20%2F%3EConnect-MsolService%20-Credential%20%24O365credential%3CBR%20%2F%3EImport-Module%20ActiveDirectory%3C%2FOFFICE%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%23%20Check%20Users%20for%20keywords%26nbsp%3Bin%20title%20and%20add%20or%20remove%20users%20from%20the%26nbsp%3BOffice%20365%20Group%3C%2FP%3E%3CP%3E%23Sets%20email%20address%20of%20all%20users%20who%20meet%20the%20criteria%3C%2FP%3E%3CP%3E%24Users%20%3D%20(get-aduser%20-SearchBase%20%22AD%20structure%20search%20base%22%20-filter%20%7B(title%20-like%20%22*Sales*%22)%7D%20-Properties%20sAMAccountName%2CTitle%2Cmail%20%7C%20select-object%20mail).mail%3C%2FP%3E%3CP%3E%23Grabs%20members%20of%20the%20Office%20365%20Group%3CBR%20%2F%3E%24UsersUnifiedGroup%20%3D%20(get-unifiedgrouplinks%20-identity%20%3COFFICE%20365%3D%22%22%20group%3D%22%22%3E%26nbsp%3B-linktype%20members%20%7C%20select-object%20primarysmtpaddress).primarysmtpaddress%3C%2FOFFICE%3E%3C%2FP%3E%3CP%3E%23Loops%20through%20object%20to%20return%20email%20addresses%20needing%20to%20be%20added%20as%20a%20variable%3CBR%20%2F%3E%24AddToUsersUnifiedGroup%20%3D%20%24Users%20%7C%20where%7B%24UsersUnifiedGroup%20-notcontains%20%24_%7D%3C%2FP%3E%3CP%3E%3CSPAN%3E%23Loops%20through%20object%20to%20return%20%3C%2FSPAN%3E%3CSPAN%3Eemail%20addresses%20needing%20to%20be%20removed%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eas%20a%20variable%3C%2FSPAN%3E%3CBR%20%2F%3E%24RemoveFromUsersUnifiedGroup%20%3D%20%24UsersUnifiedGroup%20%7C%20where%7B%24Users%20-notcontains%20%24_%7D%3C%2FP%3E%3CP%3E%23Loop%20to%20add%20users%20to%20the%20Office%20365%20Group%3CBR%20%2F%3Eforeach(%24AddToUsersUnifiedGroupEmail%20in%20%24AddToUsersUnifiedGroup)%20%7Badd-unifiedgrouplinks%20-identity%20%3COFFICE%20365%3D%22%22%20group%3D%22%22%3E%26nbsp%3B-links%20%24AddToUsersUnifiedGroupEmail%20-linktype%20members%20-confirm%3A%24false%7D%3C%2FOFFICE%3E%3C%2FP%3E%3CP%3E%23Loop%20to%20remove%20users%20from%20the%20Office%20365%20Group%3CBR%20%2F%3Eforeach(%24RemoveFromUsersUnifiedGroupEmail%20in%20%24RemoveFromUsersUnifiedGroup)%20%7Bremove-unifiedgrouplinks%20-identity%20%3COFFICE%20365%3D%22%22%20group%3D%22%22%3E%26nbsp%3B-links%20%24RemoveFromUsersUnifiedGroupEmail%20-linktype%20members%20-confirm%3A%24false%7D%3C%2FOFFICE%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-46690%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-46690%22%20slang%3D%22en-US%22%3E%3CP%3EWould%20love%20to%20see%20dynamic%20Office%20365%20Group%20functionality%26nbsp%3Bwithout%20AAD%20Premium%20licenses!%20A%20dynamic%20group%20is%20great%20for%20areas%20such%20as%20when%20adding%20a%20new%20student%20to%20their%20respective%20graduating%20year%20%22group%22.%20Or%20all%20students%20to%20a%20%22All%20Students%22%20group%2C%20new%20employee%20to%20an%20%22All%20Employees%22%20group%2C%20etc.%20Dynamic%20Exchange%20groups%20make%20this%20easy.%3CBR%20%2F%3E%3CBR%20%2F%3EAn%20as%20a%20side%20note%2C%20being%20able%20to%20%22nest%22%20the%20new%20Office%20365%20groups%20would%20make%20management%20of%20these%20groups%20much%20easier%20as%20well.%20An%20example%20is%20custodians%2C%20kitchen%2C%20office%20staff%2C%20all%20members%20of%20%22Employees%20-%20Other%22%2C%20%22Teachers%20-%20Middle%20School%22%2C%20%22Teachers%20-%20Grade%20School%22%2C%20%22Teachers%20-%20High%20School%22%20groups%20all%20members%26nbsp%3Bof%20%22Teachers%22%2C%20and%20Teachers%20and%20%22Employees%20-%20Other%22%20groups%20both%20members%20of%20an%20%22All%20Employees%22%20group.%20Works%20well%20with%20nested%20distribution%20groups%20or%20nested%20security%20groups%2C%20but%20I%20have%20to%20manage%20many%20more%20group%20members%20with%20the%20new%20Groups.%20A%20step%20back%20in%20manageability.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-21903%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-21903%22%20slang%3D%22en-US%22%3E%3CP%3Ecorrect%20in%20that%20case%20the%20owner%20will%20have%20to%20manage%20the%20members.%20I%20highly%20recommend%20in%20that%20case%20to%20have%20multiple%20owners.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-21891%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-21891%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20link%20to%20the%20documentation.%26nbsp%3B%20If%20we%20don't%20have%20the%20premium%20Azure%20AD%2C%20and%20we%20convert%20Dynamic%20distribution%20lists%20that%20were%20set%20up%20in%20Exchange%20to%20%22Groups%22%20would%20the%20membership%20in%20that%20group%20then%20have%20to%20be%20maintained%20by%20the%20Group%20owner%3F%3C%2FP%3E%3CP%3EI%20am%20creating%20some%20documentation%20for%20our%20users%20and%20I%20noticed%20that%20using%20the%20People%20directory%20shows%20Dynamic%20Distribution%20lists%2C%20but%20doesn't%20show%20the%20membership.%26nbsp%3B%20I%20was%20thinking%20of%20converting%20to%20Groups%2C%20but%20will%20have%20to%20work%20out%20the%20maintenance%20of%20membership.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6636%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6636%22%20slang%3D%22en-US%22%3E%3CP%3EOfficial%20AAD%20documentation%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fdocumentation%2Farticles%2Factive-directory-accessmanagement-manage-groups%2F%23how-can-i-create-a-simple-rule-to-manage-members-of-a-group-dynamically%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fdocumentation%2Farticles%2Factive-directory-accessmanagement-manage-groups%2F%23how-can-i-create-a-simple-rule-to-manage-members-of-a-group-dynamically%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-5958%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-5958%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1547%22%20target%3D%22_blank%22%3E%40Santhosh%20Balakrishnan%3C%2FA%3E%26nbsp%3Bis%20correct%2C%20you%20need%20AAD%20Premium%20to%20get%20this%20working%20out%20of%20the%20box.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20if%20you%20are%20a%20bit%20into%20Powershell%20scripting%20then%20you%20should%20be%20able%20to%20write%20a%20script%20that%20can%20read%20a%20users%20security%20group%20profile%20(retrieved%20from%20AD%20using%20AD%20Connect)%20and%20add%20members%20to%20unified%20groups%20using%20the%20%3CEM%3EAdd-UnifiedGroupLinks%3C%2FEM%3E%20cmdlet%20to%20add%20members%20to%20a%20unifiedgroup%20based%20on%20a%20security%20profile.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-5944%22%20slang%3D%22en-US%22%3ERe%3A%20Dynamic%20Office%20365%20groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-5944%22%20slang%3D%22en-US%22%3E%3CP%3EIt%20is%20available%20with%20Azure%20AD%20premium%20subscription.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Any chance for dynamic Office 365 groups? 

 

Let's say, a new employee is hired for an organization. This person should be added automatically to this organization's Office 365 group to enable her/him to join the organization's team work, calendars, etc.

11 Replies
best response confirmed by Kari Vääränen (New Contributor)
Solution

It is available with Azure AD premium subscription. 

@Santhosh Balakrishnan is correct, you need AAD Premium to get this working out of the box.

 

However, if you are a bit into Powershell scripting then you should be able to write a script that can read a users security group profile (retrieved from AD using AD Connect) and add members to unified groups using the Add-UnifiedGroupLinks cmdlet to add members to a unifiedgroup based on a security profile.

 

Thanks for the link to the documentation.  If we don't have the premium Azure AD, and we convert Dynamic distribution lists that were set up in Exchange to "Groups" would the membership in that group then have to be maintained by the Group owner?

I am creating some documentation for our users and I noticed that using the People directory shows Dynamic Distribution lists, but doesn't show the membership.  I was thinking of converting to Groups, but will have to work out the maintenance of membership.

correct in that case the owner will have to manage the members. I highly recommend in that case to have multiple owners.

Would love to see dynamic Office 365 Group functionality without AAD Premium licenses! A dynamic group is great for areas such as when adding a new student to their respective graduating year "group". Or all students to a "All Students" group, new employee to an "All Employees" group, etc. Dynamic Exchange groups make this easy.

An as a side note, being able to "nest" the new Office 365 groups would make management of these groups much easier as well. An example is custodians, kitchen, office staff, all members of "Employees - Other", "Teachers - Middle School", "Teachers - Grade School", "Teachers - High School" groups all members of "Teachers", and Teachers and "Employees - Other" groups both members of an "All Employees" group. Works well with nested distribution groups or nested security groups, but I have to manage many more group members with the new Groups. A step back in manageability. 

I am not a great coder or scripter but I was able to come up with the following solution.

 

I created a powershell script that iterates through the AD structure automatically adding users to the Office 365 group based off of job titles.  I have this scheduled in task manager on our DC that hosts the AAD Connect software to run once a day adding and removing users from the Office 365 Group.  The criteria can be changed to look at any field in the AD structure.

 

#Sets up the powershell environment retrieving an encrypted password from a text file decrypting it and storing the password in the $O365credential variable

$pwdloc=Join-Path (Split-Path $profile) creds.txt
$O365password = gc $pwdloc
$o365password = ConvertTo-SecureString $O365password -Force
import-module msonline
$O365username = '<office 365 username>'
$O365credential = New-Object System.Management.Automation.PSCredential -ArgumentList $O365username,$O365password
$sessionProxy = New-PSSessionOption -ProxyAccessType IEConfig -ea stop
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $O365credential -Authentication Basic -AllowRedirection -ea stop
Import-PSSession $Session -AllowClobber -DisableNameChecking -ea stop
Connect-MsolService -Credential $O365credential
Import-Module ActiveDirectory


# Check Users for keywords in title and add or remove users from the Office 365 Group

#Sets email address of all users who meet the criteria

$Users = (get-aduser -SearchBase "AD structure search base" -filter {(title -like "*Sales*")} -Properties sAMAccountName,Title,mail | select-object mail).mail

#Grabs members of the Office 365 Group
$UsersUnifiedGroup = (get-unifiedgrouplinks -identity <Office 365 Group> -linktype members | select-object primarysmtpaddress).primarysmtpaddress

#Loops through object to return email addresses needing to be added as a variable
$AddToUsersUnifiedGroup = $Users | where{$UsersUnifiedGroup -notcontains $_}

#Loops through object to return email addresses needing to be removed as a variable
$RemoveFromUsersUnifiedGroup = $UsersUnifiedGroup | where{$Users -notcontains $_}

#Loop to add users to the Office 365 Group
foreach($AddToUsersUnifiedGroupEmail in $AddToUsersUnifiedGroup) {add-unifiedgrouplinks -identity <Office 365 Group> -links $AddToUsersUnifiedGroupEmail -linktype members -confirm:$false}

#Loop to remove users from the Office 365 Group
foreach($RemoveFromUsersUnifiedGroupEmail in $RemoveFromUsersUnifiedGroup) {remove-unifiedgrouplinks -identity <Office 365 Group> -links $RemoveFromUsersUnifiedGroupEmail -linktype members -confirm:$false}

Hi Jared,

 

  If you work in the public education sector, talk to your Microsoft Licensing representative. There are other licensing options available to you that may allow you to use Dynamic Groups without having Azure Premium.

Has anyone tried this specifically for Office 365 groups? I only have the option under newly created security groups, and only when they are created. Does the dynamic rule run on a schedule, or triggered somehow for a new user? Because from what I can see it's only done upon group creation.

Alexander it works fine but make sure you read this article if you want to convert an Office 365 group from static to dynamic membership (you'll need to run a PowerShell cmdlets. Membership refreshes on a regular basis. try it out!

I've tested this in a UAT Tenant and it's worked successfully. Cheers!