Home

"My Groups" list for SharePoint Homepage Web Part

%3CLINGO-SUB%20id%3D%22lingo-sub-44824%22%20slang%3D%22en-US%22%3E%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-44824%22%20slang%3D%22en-US%22%3E%3CP%3ESo%2C%20we%20are%20about%20to%20do%20some%20major%20rollout%20of%20Groups%20to%20our%20company.%20%26nbsp%3BWhile%20there%20are%20a%20million%20%22entry%20points%22%20for%20Groups%2C%20we%20simply%20wanted%20a%20list%20of%20Groups%20that%20a%20member%20belongs%20to%20on%20our%20Intranet%20Homepage%2C%20with%20quick%20links%20to%20each%20of%20the%20major%20workloads.%20%26nbsp%3BWe%20try%20to%20drive%20all%20users%20to%20our%20Intranet%20homepage%20as%20an%20easy%20means%20to%20accessing%20information%2C%20until%20(if%20ever)%20they%20become%20more%20comfortable%20navigating%20all%20of%20the%20tools%20themselves.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20put%20together%20a%20quick%20script%20that%20will%20show%20(1)%20What%20groups%20I%20(the%20current%20user)%20belong%20to%20(item%20level%20permissions)%2C%20(2)%20Links%20to%20the%20major%20workloads%20associated%20with%20that%20Group%20(excluding%20Planner%20cause%20havent%20figured%20that%20out%20yet)%2C%20(3)%20other%20supporting%20information%20about%20the%20Group.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20we%20can%20serve%20it%20up%20on%20our%20Intranet%20Homepage%20(with%20list%20web%20part%2C%20search%20results%2Bdisplay%20templates%2C%20script%20editor%20web%20part%2C%20however%20else)%20as%20%22My%20Groups%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20also%20serves%20as%20an%20%22auditing%22%20list%20for%20us%20admins%20(we%20can%20see%20what%20groups%20exist%2C%20which%20language%2C%20what%20category%2Fclassification%2C%20dynamic%20membership%2C%20etc).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F10640i81CD484C23E21AF5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22groups_inventory.png%22%20title%3D%22groups_inventory.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EProbably%20more%20elegant%20ways%20to%20do%20this%20(and%20probably%20better%20SPFX%20stuff%20in%20the%20future%2C%20but%20I%20only%20know%20what%20I%20know)%2C%20but%20in%20general%2C%20I%20am%20just%20clearing%20a%20SharePoint%20list%20of%20existing%20entries%2C%20querying%20all%20O365%20Groups%2C%20and%20adding%20them%20into%20the%20SharePoint%20list%2C%20and%20then%20setting%20%22Read%22%20permissions%20on%20the%20list%20item%20to%20the%20particular%20Group%20(so%20only%20Group%20members%20can%20actually%20see%20their%20own%20Groups).%20%26nbsp%3BProbably%20running%20this%20once%20or%20twice%20a%20day.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%23%20SharePoint%20Online%20DLLs%0A%23%24dllDirectory%20%3D%20%22D%3A%5CAssets%5C%5C16.1.6112.1200%22%0A%24dllDirectory%20%3D%20%22C%3A%5CPowerShell%5CDLL%5C16.1.6112.1200%22%0AAdd-Type%20-Path%20%22%24dllDirectory%5CMicrosoft.SharePoint.Client.dll%22%20%0AAdd-Type%20-Path%20%22%24dllDirectory%5CMicrosoft.SharePoint.Client.Runtime.dll%22%20%0A%0A%23%20User%20Credentials%20and%20Variables%20%0A%24username%20%3D%20%22%26lt%3Badmin%20username%20here%26gt%3B%22%0A%24password%20%3D%20'%26lt%3Badmin%20password%20here%26gt%3B'%0A%24securePassword%20%3D%20ConvertTo-SecureString%20%24Password%20-AsPlainText%20-Force%20%0A%24url%20%3D%20%22https%3A%2F%2Fcontoso.sharepoint.com%2Fsites%2Fgroups%2F%22%20%23%20the%20url%20of%20the%20site%20where%20your%20list%20is%0A%24listName%20%3D%20%22Groups%22%20%23%20the%20name%20of%20your%20list%0A%24domain%20%3D%20%22%40contoso.com%22%0A%0A%23%20Connect%20to%20Exchange%20Online%0AWrite-Host%20%22Connecting%20to%20Exchange%20Online...%22%20-ForegroundColor%20Green%20%0A%24E_Credential%20%3D%20New-Object%20-TypeName%20System.Management.Automation.PSCredential%20-argumentlist%20%24userName%2C%20%24SecurePassword%0A%24Session%20%3D%20New-PSSession%20-ConfigurationName%20Microsoft.Exchange%20-ConnectionUri%20https%3A%2F%2Fps.outlook.com%2Fpowershell%2F%20-Credential%20%24E_Credential%20-Authentication%20Basic%20-AllowRedirection%0AImport-PSSession%20%24Session%20-AllowClobber%20%20%7C%20out-null%0A%0A%23%20Connect%20to%20SPO%0A%24clientContext%20%3D%20New-Object%20Microsoft.SharePoint.Client.ClientContext(%24url)%20%0A%24credentials%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24username%2C%20%24securePassword)%20%0A%24clientContext.Credentials%20%3D%20%24credentials%20%0AWrite-Host%20%22Connected%20to%3A%20'%24Url'%22%20-ForegroundColor%20Green%20%0A%20%0A%24List%20%3D%20%24clientContext.Web.Lists.getByTitle(%24listName)%0A%24clientContext.Load(%24List)%0A%24clientContext.ExecuteQuery()%0A%0A%23%20Get%20Existing%20Entries%0A%24spQuery%20%3D%20New-Object%20Microsoft.SharePoint.Client.CamlQuery%20%0A%24items%20%3D%20%24List.GetItems(%24spQuery)%0A%24clientContext.Load(%24items)%0A%24clientContext.ExecuteQuery()%0A%0A%23%20Remove%20Existing%20Entries%0AWrite-Host%20%22Clearing%20existing%20entries%22%20-ForegroundColor%20Cyan%0A%24count%20%3D%200%0AForEach%20(%24item%20in%20%24items)%7B%0A%20%20%20%20Write-Host%20(%22%20%20%22%2B%24count%2B%22%20%22%2B%24Item.FieldValues%5B%22ID%22%5D%2B%22%20%22%2B%24Item.FieldValues%5B%22Title%22%5D)%0A%20%20%20%20%24List.getitembyid(%24Item.id).DeleteObject()%0A%20%20%20%20%24clientContext.ExecuteQuery()%0A%20%20%20%20%24count%20%2B%3D%201%0A%7D%0A%0A%23%20Get%20all%20O365%20Groups%0AWrite-Host%20%22Getting%20O365%20Groups%22%20-ForegroundColor%20Cyan%0A%24o365Groups%20%3D%20get-unifiedgroup%0A%24count%20%3D%200%0Aforeach(%24group%20in%20%24o365Groups)%7B%0A%20%20%20%20%24count%2B%2B%0A%20%20%20%20Write-Host%20%22%24count%20-%20Creating%20%24(%24group.DisplayName)%22%20-ForegroundColor%20Green%0A%20%20%20%20%23%24group%20%7C%20select%20*%20%23%20Show%20all%20available%20Group%20details%0A%0A%20%20%20%20%24O365_group%20%3D%20%24clientContext.Site.RootWeb.EnsureUser(%22c%3A0o.c%7Cfederateddirectoryclaimprovider%7C%24(%24group.ExternalDirectoryObjectId)%22)%0A%20%20%20%20%24clientContext.Load(%24O365_group)%0A%0A%20%20%20%20%5BMicrosoft.SharePoint.Client.FieldUserValue%5B%5D%5D%24groupOwners%20%3D%20New-Object%20Microsoft.SharePoint.Client.FieldUserValue%0A%20%20%20%20%24owners%20%3D%20(%24group.ManagedBy)%0A%20%20%20%20foreach(%24owner%20in%20%24owners)%7B%0A%20%20%20%20%20%20%20%20try%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24user%20%3D%20%24clientContext.Web.EnsureUser(%22%24owner%40buckman.com%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%24clientContext.Load(%24user)%0A%20%20%20%20%20%20%24clientContext.ExecuteQuery()%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%5BMicrosoft.SharePoint.Client.FieldUserValue%5D%24fieldUser%20%3D%20New-Object%20Microsoft.SharePoint.Client.FieldUserValue%0A%20%20%20%20%20%20%20%20%20%20%20%20%24fieldUser.LookupId%20%3D%20%24user.Id%0A%20%20%20%20%20%20%20%20%20%20%20%20if(%24counter%20-eq%200)%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24groupOwners%20%3D%20%24fieldUser%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24groupOwners%20%2B%3D%20%24fieldUser%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%24counter%2B%2B%0A%20%20%20%20%20%20%20%20%7D%20catch%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22User%20does%20not%20exist%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%0A%20%20%20%20%23%20Create%20new%20entry%20in%20SharePoint%20List%0A%20%20%20%20%23%20Change%20the%20%5B%22field%22%5D%20values%20to%20match%20your%20SharePoint%20column%20internal%20names%0A%20%20%20%20%24ListItemInfo%20%3D%20New-Object%20Microsoft.SharePoint.Client.ListItemCreationInformation%0A%20%20%20%20%24newItem%20%3D%20%24List.AddItem(%24ListItemInfo)%0A%20%20%20%20%24newItem%5B%22Title%22%5D%20%3D%20%24group.DisplayName%20%23%20Single%20Line%20of%20Text%0A%20%20%20%20%24newItem%5B%22Group%22%5D%20%3D%20%24O365_group%20%23%20Person%2FGroup%20Field%20(Group%20enabled)%20%20%20%20%0A%20%20%20%20%24newItem%5B%22Description%22%5D%20%3D%20%24group.Notes%20%23%20Multiple%20Lines%20of%20Text%0A%20%20%20%20%24newItem%5B%22Conversation%22%5D%20%3D%20%22https%3A%2F%2Foutlook.office.com%2Fowa%2F%3Fpath%3D%2Fgroup%2F%24(%24group.Alias)%24(%24domain)%2Fmail%2C%20Conversation%22%20%23%20Hyperlink%0A%20%20%20%20%24newItem%5B%22Calendar%22%5D%20%3D%20%22https%3A%2F%2Foutlook.office.com%2Fowa%2F%3Fpath%3D%2Fgroup%2F%24(%24group.Alias)%24(%24domain)%2Fcalendar%2C%20Calendar%22%20%23%20Hyperlink%0A%20%20%20%20%24newItem%5B%22Files%22%5D%20%3D%20%22https%3A%2F%2Foutlook.office.com%2Fowa%2F%3Fpath%3D%2Fgroup%2F%24(%24group.Alias)%24(%24domain)%2Ffiles%2C%20Files%22%20%23%20Hyperlink%0A%20%20%20%20%24newItem%5B%22Library%22%5D%20%3D%20%22%24(%24group.SharePointDocumentsUrl)%2C%20Document%20Library%22%20%23%20Hyperlink%0A%20%20%20%20%24newItem%5B%22Site%22%5D%20%3D%20%22%24(%24group.SharePointSiteUrl)%2C%20SharePoint%20Site%22%20%23%20Hyperlink%0A%20%20%20%20%24newItem%5B%22Notebook%22%5D%20%3D%20%22%24(%24group.SharePointNotebookUrl)%2C%20Notebook%22%20%23%20Hyperlink%0A%20%20%20%20%24newItem%5B%22Category%22%5D%20%3D%20%24group.Classification%20%23%20Single%20Line%20of%20Text%0A%20%20%20%20%24newItem%5B%22Connectors%22%5D%20%3D%20%24group.ConnectorsEnabled%20%23%20Boolean%20(Yes%2FNo)%0A%20%20%20%20%24newItem%5B%22HiddenFromGAL%22%5D%20%3D%20%24group.HiddenFromAddressListsEnabled%20%23%20Boolean%20(Yes%2FNo)%0A%20%20%20%20%24newItem%5B%22Language%22%5D%20%3D%20%24group.Language%20%23%20Single%20Line%20of%20Text%0A%20%20%20%20%24newItem%5B%22Privacy%22%5D%20%3D%20%24group.AccessType%20%23%20Single%20Line%20of%20Text%0A%20%20%20%20%24newItem%5B%22DynamicMembership%22%5D%20%3D%20%24group.IsMembershipDynamic%20%23%20Boolean%20(Yes%2FNo)%0A%20%20%20%20%24newItem%5B%22ExternalDirectoryID%22%5D%20%3D%20%24group.ExternalDirectoryObjectId%20%23%20Single%20Line%20of%20Text%20%20%20%0A%20%20%20%20%24newItem%5B%22ExternalUserCount%22%5D%20%3D%20%24group.GroupExternalMemberCount%20%23%20Number%20%20%20%0A%20%20%20%20%24newItem%5B%22Owners%22%5D%20%3D%20%24groupOwners%20%23%20Multiple%20Person%20Field%0A%20%20%20%20%23%20Add%20more%20as%20needed%0A%20%20%20%20%24newItem.Update()%0A%20%20%20%20%24clientContext.ExecuteQuery()%0A%0A%20%20%20%20%23%20Break%20Permissions%0A%20%20%20%20%24newItem.BreakRoleInheritance(%24false%2C%20%24false)%20%20%0A%20%20%20%20%24clientContext.ExecuteQuery()%20%20%0A%0A%20%20%20%20%23%20Remove%20Any%20Existing%20Permissions%0A%20%20%20%20%24permissions%20%3D%20%24newItem.RoleAssignments%0A%20%20%20%20%24clientContext.Load(%24permissions)%0A%20%20%20%20%24clientContext.ExecuteQuery()%0A%20%20%20%20foreach(%24permission%20in%20%24permissions)%7B%0A%20%20%20%20%20%20%20%20%24newItem.RoleAssignments.GetByPrincipalId(%24permission.PrincipalId).DeleteObject()%0A%20%20%20%20%7D%0A%0A%20%20%20%20%23%20Set%20permissions%20to%20actual%20O365%20Group%0A%20%20%20%20%24reader%20%3D%20%24clientContext.Web.RoleDefinitions.GetByName(%22Read%22)%3B%0A%20%20%20%20%24roleAssignment%20%3D%20New-Object%20microsoft.SharePoint.Client.RoleDefinitionBindingCollection(%24clientContext)%0A%20%24roleAssignment.Add(%24reader)%0A%20%20%20%20%24clientContext.Load(%24newItem.RoleAssignments.Add(%24O365_group%2C%20%24roleAssignment))%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%24newItem.Update()%3B%20%20%0A%20%20%20%20%24clientContext.ExecuteQuery()%0A%0A%7D%0A%0A%0A%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-44824%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EGroups%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Groups%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-294775%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294775%22%20slang%3D%22en-US%22%3E%3CP%3EMy%20again!%20Any%20insight%20on%20how%20to%20pull%20in%20Team%20conversations%20or%20planner%20URLs%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-294698%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294698%22%20slang%3D%22en-US%22%3E%3CP%3ESolved%2C%20needed%20to%20establish%20the%20HTML%20variable%26nbsp%3Band%20change%20the%20Title%20Html%20to%20html%2B.%20Thanks%20for%20this%20work!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-294351%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294351%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F637%22%20target%3D%22_blank%22%3E%40Brent%20Ellis%3C%2FA%3E%26nbsp%3Bthanks!%20that%20fixed%20it!%20One%20more%20question%20(please%20forgive%20me%20I%20am%20pretty%20novice%20at%20jquery)%20it%20doesn't%20seem%20to%20be%20storing%20all%20the%20groups%20it's%20looping%20through.%20I%20am%20only%20seeing%20the%20last%20group%20displayed.%20Any%20insight%20on%20how%20to%20fix%20this%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-294294%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294294%22%20slang%3D%22en-US%22%3EPerhaps%20my%20mistake%20in%20a%20poor%20copy%20paste%2C%20it%20looks%20like%3CBR%20%2F%3E%24(%22%23listOfGroups%22).html(str)%3B%3CBR%20%2F%3Eshould%20be%3CBR%20%2F%3E%24(%22%23listOfGroups%22).html(html)%3B%3CBR%20%2F%3Ein%20the%20above%20example%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-294279%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294279%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F637%22%20target%3D%22_blank%22%3E%40Brent%20Ellis%3C%2FA%3E%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20recreate%20the%26nbsp%3B%3CSPAN%3Eend-user%20visual%20web%20part%20based%20on%20the%20script%20you%20provided.%20However%2C%20I%26nbsp%3Bam%20not%20getting%20anything%20populated%20(the%20API%20is%20set%2C%20I%20just%20can't%20get%20the%20records%20to%26nbsp%3Bdisplay%3F%20The%20Str%20is%20not%20defined%3F%20Any%20insight%20on%20this%3F%20Any%20help%20is%20appreciated.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-130421%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-130421%22%20slang%3D%22en-US%22%3E%3CP%3EGreat%20code!%20Used%20it%20with%20the%20combination%20of%20Promoted%20Links.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-48305%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-48305%22%20slang%3D%22en-US%22%3E%3CP%3ECan%20confirm%20-%20that%20is%20pretty%20ridiculous%20and%20needs%20to%20be%20fixed%20asap%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20600px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F11172i3AC722FF900E716E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Groups%20not%20in%20search.png%22%20title%3D%22Groups%20not%20in%20search.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-48039%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-48039%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20could%20easily%20test%20it%20by%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20creating%20a%20list%3C%2FP%3E%3CP%3E2.%20add%20an%20item%2C%20remove%20all%20permissions%20and%20add%20assign%20permissions%20to%20an%20O365%20group%3C%2FP%3E%3CP%3E3.%20index%20the%20list%3C%2FP%3E%3CP%3E4.%20try%20to%20search%20for%20the%20item%20with%20a%20user%20account%20given%20permission%20through%20the%20O365%20only%20on%20that%20item%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20unable%20to%20get%20the%20item%20back%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-48000%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-48000%22%20slang%3D%22en-US%22%3E%3CP%3EHmm%2C%20I%20opted%20to%20use%20api%20and%20script%20editor%20web%20part%20to%20create%20our%20web%20part%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPerhaps%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F67%22%20target%3D%22_blank%22%3E%40Christophe%20Fiessinger%3C%2FA%3E%26nbsp%3Bcan%20flag%20someone%20down%20that%20knows%20how%20search%20indexing%20%2B%20Groups%20is%20working.%20%26nbsp%3BWe%20havent%20started%20using%20Groups%20for%20permissions%20elsewhere%20yet%2C%20but%20are%20definitely%20planning%20to%20and%20if%20this%20is%20the%20case%2C%20that%20is%20a%20big%20issue.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%26lt%3BSCRIPT%20LANGUAGE%3D'JavaScript'%20type%3D'text%2Fjavascript'%26gt%3B%0A%0A%24(document).ready(function%20()%20%7B%0A%0A%20%24.ajax(%7B%0A%20%20url%20%3A%20%22https%3A%2F%2Fmytenant.sharepoint.com%2Fsites%2Fgroups%2F_api%2Fweb%2Flists%2FgetByTitle('my')%2FItems%3F%24OrderBy%3DTitle%22%2C%0A%20%20contentType%20%3A%20%22application%2Fjson%3Bodata%3Dverbose%22%2C%0A%20%20headers%20%3A%20%7B%20%22accept%22%20%3A%20%22application%2Fjson%3Bodata%3Dverbose%22%20%7D%2C%0A%20%20success%20%3A%20function%20onSuccess(data%2C%20request)%7B%0A%20%20%20if(data.d.results.length%20%3D%3D%200)%7B%0A%20%20%20%20%24(%22%23listOfGroups%22).html(%22No%20Groups%22)%3B%0A%20%20%20%7D%20else%20%7B%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20for(i%3D0%3Bi%26lt%3Bdata.d.results.length%3Bi%2B%2B)%7B%0A%20%20%20%20%20%2F%2Fconsole.log(data.d.results%5Bi%5D)%3B%0A%20%20%20%20%20html%20%3D%20%22%26lt%3BB%26gt%3B%22%2Bdata.d.results%5Bi%5D.Title%2B%22%26lt%3B%2FB%26gt%3B%26lt%3BBR%26gt%3B%22%0A%20%20%20%20%20if(data.d.results%5Bi%5D.Conversation)%7B%0A%20%20%20%20%20%20html%20%2B%3D%20%22%26lt%3Ba%20style%3D'font-size%3A16px%3B'%20title%3D'Group%20Conversations'%20href%3D'%22%2Bdata.d.results%5Bi%5D.Conversation.Url%2B%22'%20target%3D'_blank'%26gt%3B%26lt%3Bi%20class%3D'fa%20fa-comments-o'%20aria-hidden%3D'true'%26gt%3B%26lt%3B%2Fi%26gt%3B%26lt%3B%2Fa%26gt%3B%20%7C%20%22%3B%0A%20%20%20%20%20%7D%0A%20%20%20%20%20if(data.d.results%5Bi%5D.Calendar)%7B%0A%20%20%20%20%20%20html%20%2B%3D%20%22%26lt%3Ba%20style%3D'font-size%3A16px%3B'%20title%3D'Group%20Calendar'%20href%3D'%22%2Bdata.d.results%5Bi%5D.Calendar.Url%2B%22'%20target%3D'_blank'%26gt%3B%26lt%3Bi%20class%3D'fa%20fa-calendar'%20aria-hidden%3D'true'%26gt%3B%26lt%3B%2Fi%26gt%3B%26lt%3B%2Fa%26gt%3B%20%7C%20%22%3B%0A%20%20%20%20%20%7D%0A%20%20%20%20%20if(data.d.results%5Bi%5D.Files)%7B%0A%20%20%20%20%20%20html%20%2B%3D%20%22%26lt%3Ba%20style%3D'font-size%3A16px%3B'%20title%3D'Group%20Files'%20href%3D'%22%2Bdata.d.results%5Bi%5D.Files.Url%2B%22'%20target%3D'_blank'%26gt%3B%26lt%3Bi%20class%3D'fa%20fa-folder-open-o'%20aria-hidden%3D'true'%26gt%3B%26lt%3B%2Fi%26gt%3B%26lt%3B%2Fa%26gt%3B%20%7C%20%22%3B%0A%20%20%20%20%20%7D%0A%20%20%20%20%20if(data.d.results%5Bi%5D.Notebook)%7B%0A%20%20%20%20%20%20html%20%2B%3D%20%22%26lt%3Ba%20style%3D'font-size%3A16px%3B'%20title%3D'Group%20Notebook'%20href%3D'%22%2Bdata.d.results%5Bi%5D.Notebook.Url%2B%22'%20target%3D'_blank'%26gt%3B%26lt%3Bi%20class%3D'fa%20fa-book'%20aria-hidden%3D'true'%26gt%3B%26lt%3B%2Fi%26gt%3B%26lt%3B%2Fa%26gt%3B%20%7C%20%22%3B%0A%20%20%20%20%20%7D%0A%20%20%20%20%20if(data.d.results%5Bi%5D.Site)%7B%0A%20%20%20%20%20%20html%20%2B%3D%20%22%26lt%3Ba%20style%3D'font-size%3A16px%3B'%20title%3D'Group%20SharePoint%20Site'%20href%3D'%22%2Bdata.d.results%5Bi%5D.Site.Url%2B%22'%20target%3D'_blank'%26gt%3B%26lt%3Bi%20class%3D'fa%20fa-sitemap'%20aria-hidden%3D'true'%26gt%3B%26lt%3B%2Fi%26gt%3B%26lt%3B%2Fa%26gt%3B%22%3B%0A%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%0A%20%20%20%20%7D%0A%0A%20%20%20%20%24(%22%23listOfGroups%22).html(str)%3B%0A%20%20%20%20%20%20%0A%20%20%20%7D%0A%20%20%20%20%20%20%20%0A%20%20%7D%2C%0A%20%20error%3A%20function%20(jqXHR%2C%20textStatus%2C%20errorThrown)%20%7B%20console.log(jqXHR)%3B%20%7D%0A%20%7D)%3B%0A%0A%7D)%3B%0A%0A%26lt%3B%2FSCRIPT%26gt%3B%0A%0A%26lt%3Bdiv%20id%3D%22listOfGroups%22%26gt%3B%26lt%3B%2Fdiv%26gt%3B%3C%2FPRE%3E%3CP%3ENote%2C%20we've%20got%20font-awesome%20embedded%20for%20the%20icons.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47979%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47979%22%20slang%3D%22en-US%22%3E%3CP%3EWe've%20hit%20a%20road%20block%20woth%20this%2C%20I'm%20not%20sure%20why.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20groups%26nbsp%3Bare%20visible%20in%20the%20generated%20list%20for%20a%20member%20of%20that%20group%2C%20but%20the%20search%20remains%20empty%20for%20that%20user%20unless%20we%20manually%2Fexplicitely%20give%26nbsp%3Bthe%20member%20rights%26nbsp%3B(which%20he%20already%20has%20through%20the%20group).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20checking%20the%20privileges%20of%20a%20user%20on%20an%20item%2C%20it%20is%20given%20by%20the%20O365%20group%2C%20but%20the%20item%20is%26nbsp%3Bonly%20visible%20in%20the%20search%20until%20the%20privileges%26nbsp%3Bare%20given%20directly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20looks%20like%20the%20search%20is%20unable%20to%20resolve%20the%20group%20members%20when%20crawling.%20It%20is%20strange%20that%20this%20is%20working%20in%20your%20tenant.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47498%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47498%22%20slang%3D%22en-US%22%3E%3CP%3EThat's%20impressive%20Brett.%20The%20in-built%20Group%20discovery%20experience%26nbsp%3Bhas%20some%20weaknesses.%20Your%20web%20part%20will%20be%20very%20useful%20for%20an%20organizations%20that%20has%26nbsp%3Bhas%20high%20adoption%20and%20utilization%20of%20their%20SPO%20Intranet.%20I%20encourage%20people%20to%20favourite%20the%20Groups%20they%20frequently%20work%20in.%20Then%20wherever%20Groups%20are%20listed%2C%20(OWA%2C%20OneDrive%2C%20SharePoint%20Home%20site%2C%20mobile%20apps)%20their%20frequent%20and%20favourite%20Groups%20are%20easy%20to%20find.%20But%20by%20using%20your%20web%20part%2C%20you%20have%20more%20control%20of%20the%20detail%20that's%20presented.%20It%20would%20be%20interested%20to%20see%20what%20you%20can%20bring%20through%20from%20the%20Microsoft%20Graph.%20You%20could%20list%20recent%20activity%2C%20recent%20conversations%2C%20next%20task%20due%20from%20Planner.%20A%20view%20like%20this%20to%20show%20your%20Group%20'at-a-glance'%20would%20be%20very%20useful.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47425%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47425%22%20slang%3D%22en-US%22%3E%3CP%3EGot%20my%20first%20end-user%20visual%20set%20up%20for%20including%20on%20our%20home%20page.%20%26nbsp%3BI'm%20using%20the%20Group%20title%2C%20with%20selectable%20icons%20underneath%20to%20each%20workload.%20%26nbsp%3BHave%20a%20quick%20filter%20text%20box%20to%20narrow%20down%20groups%20and%20a%20small%20pagination%20to%20save%20real%20estate.%20%26nbsp%3BThen%20a%20link%20at%20the%20bottom%20to%20go%20to%20our%20%22Informational%22%20page%20about%20Groups.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20537px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F11050i57F0D3A5251FA5EC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22MyGroupsWebPart.jpg%22%20title%3D%22MyGroupsWebPart.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-45785%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45785%22%20slang%3D%22en-US%22%3EThanks%20Bart!%20This%20is%20my%20quick%20and%20dirty%20attempt%20to%20solve%20an%20immediate%20need%2C%20thought%20I%20sanitized%20it%20enough%20before%20pasting%20but%20missed%20the%20domain%20%3A)%3C%2Fimg%3E%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20hardly%20a%20powershell%20expert%2C%20but%20more%20than%20armed%20and%20dangerous%2C%20so%20I'm%20sure%20there%20are%20many%20more%20efficiencies%20to%20be%20had.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-45368%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45368%22%20slang%3D%22en-US%22%3E%3CP%3EPure%20beauty%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESome%20things%20I%20didn't%20know%20and%20might%20be%26nbsp%3Bhelpful%20to%20others%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-%20don't%20forget%20to%20change%26nbsp%3B%40buckman.com%20to%20the%20domain%20you%20use%20for%20your%20O365%20groups%20(I%20wonder%20if%20the%20script%20can%20be%20updated%20to%20detect%20the%20domain%20since%20you%20can%20use%20multiple%20domains%3F)%3C%2FP%3E%3CP%3E-%20you%20can%20download%20the%20dll's%20from%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.SharePointOnline.CSOM%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.SharePointOnline.CSOM%3C%2FA%3E%20(just%20download%20the%20nuget%20package%26nbsp%3Band%20change%20the%20extension%20to%20zip)%3C%2FP%3E%3CP%3E-%20Roldefinitions%20are%20localized%20so%20instead%20of%26nbsp%3B%24clientContext.Web.RoleDefinitions.GetByName(%22Read%22)%2C%20I%20had%20to%20use%26nbsp%3BGetByName(%22Lezen%22)%3B%20(check%20the%20permission%20levels%20on%20your%20list)%3C%2FP%3E%3CP%3E-%20if%20you%20have%201000%2B%20groups%2C%20you%20could%20try%20get-unifiedgroup%20-resultsize%20unlimited%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-44921%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-44921%22%20slang%3D%22en-US%22%3EVery%20impressive%2C%20I%20wish%20some%20of%20this%20was%20built%20in!!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-44908%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-44908%22%20slang%3D%22en-US%22%3E%3CP%3EGreat%20stuff%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F637%22%20target%3D%22_blank%22%3E%40Brent%20Ellis%3C%2FA%3E!%20As%20you%20mentioned%2C%20would%20love%20to%20see%20this%20in%20SPFx%20form%20or%20potentially%20as%20%22My%20Groups%20Bot%22%20embedded%20in%20Microsoft%20Teams!%20The%20bot%20could%20help%20drive%20action%20around%20the%20Groups%20right%20there%20in%20the%20conversation%20for%20basic%20group%20maintenance%2C%20discovery%2C%20etc.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-44889%22%20slang%3D%22en-US%22%3ERe%3A%20%22My%20Groups%22%20list%20for%20SharePoint%20Homepage%20Web%20Part%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-44889%22%20slang%3D%22en-US%22%3E%3CP%3EWow!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Brent Ellis
Valued Contributor

So, we are about to do some major rollout of Groups to our company.  While there are a million "entry points" for Groups, we simply wanted a list of Groups that a member belongs to on our Intranet Homepage, with quick links to each of the major workloads.  We try to drive all users to our Intranet homepage as an easy means to accessing information, until (if ever) they become more comfortable navigating all of the tools themselves.

 

So I put together a quick script that will show (1) What groups I (the current user) belong to (item level permissions), (2) Links to the major workloads associated with that Group (excluding Planner cause havent figured that out yet), (3) other supporting information about the Group.

 

Now we can serve it up on our Intranet Homepage (with list web part, search results+display templates, script editor web part, however else) as "My Groups"

 

This also serves as an "auditing" list for us admins (we can see what groups exist, which language, what category/classification, dynamic membership, etc).

 

groups_inventory.png

Probably more elegant ways to do this (and probably better SPFX stuff in the future, but I only know what I know), but in general, I am just clearing a SharePoint list of existing entries, querying all O365 Groups, and adding them into the SharePoint list, and then setting "Read" permissions on the list item to the particular Group (so only Group members can actually see their own Groups).  Probably running this once or twice a day.

 

 

# SharePoint Online DLLs
#$dllDirectory = "D:\Assets\\16.1.6112.1200"
$dllDirectory = "C:\PowerShell\DLL\16.1.6112.1200"
Add-Type -Path "$dllDirectory\Microsoft.SharePoint.Client.dll" 
Add-Type -Path "$dllDirectory\Microsoft.SharePoint.Client.Runtime.dll" 

# User Credentials and Variables 
$username = "<admin username here>"
$password = '<admin password here>'
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force 
$url = "https://contoso.sharepoint.com/sites/groups/" # the url of the site where your list is
$listName = "Groups" # the name of your list
$domain = "@contoso.com"

# Connect to Exchange Online
Write-Host "Connecting to Exchange Online..." -ForegroundColor Green 
$E_Credential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $SecurePassword
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $E_Credential -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber  | out-null

# Connect to SPO
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url) 
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword) 
$clientContext.Credentials = $credentials 
Write-Host "Connected to: '$Url'" -ForegroundColor Green 
	
$List = $clientContext.Web.Lists.getByTitle($listName)
$clientContext.Load($List)
$clientContext.ExecuteQuery()

# Get Existing Entries
$spQuery = New-Object Microsoft.SharePoint.Client.CamlQuery	
$items = $List.GetItems($spQuery)
$clientContext.Load($items)
$clientContext.ExecuteQuery()

# Remove Existing Entries
Write-Host "Clearing existing entries" -ForegroundColor Cyan
$count = 0
ForEach ($item in $items){
    Write-Host ("  "+$count+" "+$Item.FieldValues["ID"]+" "+$Item.FieldValues["Title"])
    $List.getitembyid($Item.id).DeleteObject()
    $clientContext.ExecuteQuery()
    $count += 1
}

# Get all O365 Groups
Write-Host "Getting O365 Groups" -ForegroundColor Cyan
$o365Groups = get-unifiedgroup
$count = 0
foreach($group in $o365Groups){
    $count++
    Write-Host "$count - Creating $($group.DisplayName)" -ForegroundColor Green
    #$group | select * # Show all available Group details

    $O365_group = $clientContext.Site.RootWeb.EnsureUser("c:0o.c|federateddirectoryclaimprovider|$($group.ExternalDirectoryObjectId)")
    $clientContext.Load($O365_group)

    [Microsoft.SharePoint.Client.FieldUserValue[]]$groupOwners = New-Object Microsoft.SharePoint.Client.FieldUserValue
    $owners = ($group.ManagedBy)
    foreach($owner in $owners){
        try{
            $user = $clientContext.Web.EnsureUser("$owner@buckman.com")
            $clientContext.Load($user)
		    $clientContext.ExecuteQuery()	                    
            [Microsoft.SharePoint.Client.FieldUserValue]$fieldUser = New-Object Microsoft.SharePoint.Client.FieldUserValue
            $fieldUser.LookupId = $user.Id
            if($counter -eq 0){
                $groupOwners = $fieldUser
            } else {
                $groupOwners += $fieldUser
            }
            $counter++
        } catch {
            Write-Host "User does not exist"
        }
    }


    # Create new entry in SharePoint List
    # Change the ["field"] values to match your SharePoint column internal names
    $ListItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
    $newItem = $List.AddItem($ListItemInfo)
    $newItem["Title"] = $group.DisplayName # Single Line of Text
    $newItem["Group"] = $O365_group # Person/Group Field (Group enabled)    
    $newItem["Description"] = $group.Notes # Multiple Lines of Text
    $newItem["Conversation"] = "https://outlook.office.com/owa/?path=/group/$($group.Alias)$($domain)/mail, Conversation" # Hyperlink
    $newItem["Calendar"] = "https://outlook.office.com/owa/?path=/group/$($group.Alias)$($domain)/calendar, Calendar" # Hyperlink
    $newItem["Files"] = "https://outlook.office.com/owa/?path=/group/$($group.Alias)$($domain)/files, Files" # Hyperlink
    $newItem["Library"] = "$($group.SharePointDocumentsUrl), Document Library" # Hyperlink
    $newItem["Site"] = "$($group.SharePointSiteUrl), SharePoint Site" # Hyperlink
    $newItem["Notebook"] = "$($group.SharePointNotebookUrl), Notebook" # Hyperlink
    $newItem["Category"] = $group.Classification # Single Line of Text
    $newItem["Connectors"] = $group.ConnectorsEnabled # Boolean (Yes/No)
    $newItem["HiddenFromGAL"] = $group.HiddenFromAddressListsEnabled # Boolean (Yes/No)
    $newItem["Language"] = $group.Language # Single Line of Text
    $newItem["Privacy"] = $group.AccessType # Single Line of Text
    $newItem["DynamicMembership"] = $group.IsMembershipDynamic # Boolean (Yes/No)
    $newItem["ExternalDirectoryID"] = $group.ExternalDirectoryObjectId # Single Line of Text   
    $newItem["ExternalUserCount"] = $group.GroupExternalMemberCount # Number   
    $newItem["Owners"] = $groupOwners # Multiple Person Field
    # Add more as needed
    $newItem.Update()
    $clientContext.ExecuteQuery()

    # Break Permissions
    $newItem.BreakRoleInheritance($false, $false)  
    $clientContext.ExecuteQuery()  

    # Remove Any Existing Permissions
    $permissions = $newItem.RoleAssignments
    $clientContext.Load($permissions)
    $clientContext.ExecuteQuery()
    foreach($permission in $permissions){
        $newItem.RoleAssignments.GetByPrincipalId($permission.PrincipalId).DeleteObject()
    }

    # Set permissions to actual O365 Group
    $reader = $clientContext.Web.RoleDefinitions.GetByName("Read");
    $roleAssignment = New-Object microsoft.SharePoint.Client.RoleDefinitionBindingCollection($clientContext)
	$roleAssignment.Add($reader)
    $clientContext.Load($newItem.RoleAssignments.Add($O365_group, $roleAssignment)) 
                                     
    $newItem.Update();  
    $clientContext.ExecuteQuery()

}


 

17 Replies

Great stuff @Brent Ellis! As you mentioned, would love to see this in SPFx form or potentially as "My Groups Bot" embedded in Microsoft Teams! The bot could help drive action around the Groups right there in the conversation for basic group maintenance, discovery, etc.

Very impressive, I wish some of this was built in!!

Pure beauty :)

 

Some things I didn't know and might be helpful to others:

 

- don't forget to change @buckman.com to the domain you use for your O365 groups (I wonder if the script can be updated to detect the domain since you can use multiple domains?)

- you can download the dll's from https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM (just download the nuget package and change the extension to zip)

- Roldefinitions are localized so instead of $clientContext.Web.RoleDefinitions.GetByName("Read"), I had to use GetByName("Lezen"); (check the permission levels on your list)

- if you have 1000+ groups, you could try get-unifiedgroup -resultsize unlimited

 

Thanks!

Thanks Bart! This is my quick and dirty attempt to solve an immediate need, thought I sanitized it enough before pasting but missed the domain :)

I'm hardly a powershell expert, but more than armed and dangerous, so I'm sure there are many more efficiencies to be had.

Got my first end-user visual set up for including on our home page.  I'm using the Group title, with selectable icons underneath to each workload.  Have a quick filter text box to narrow down groups and a small pagination to save real estate.  Then a link at the bottom to go to our "Informational" page about Groups.

 

MyGroupsWebPart.jpg

That's impressive Brett. The in-built Group discovery experience has some weaknesses. Your web part will be very useful for an organizations that has has high adoption and utilization of their SPO Intranet. I encourage people to favourite the Groups they frequently work in. Then wherever Groups are listed, (OWA, OneDrive, SharePoint Home site, mobile apps) their frequent and favourite Groups are easy to find. But by using your web part, you have more control of the detail that's presented. It would be interested to see what you can bring through from the Microsoft Graph. You could list recent activity, recent conversations, next task due from Planner. A view like this to show your Group 'at-a-glance' would be very useful.

We've hit a road block woth this, I'm not sure why.

 

The groups are visible in the generated list for a member of that group, but the search remains empty for that user unless we manually/explicitely give the member rights (which he already has through the group).

 

When checking the privileges of a user on an item, it is given by the O365 group, but the item is only visible in the search until the privileges are given directly.

 

It looks like the search is unable to resolve the group members when crawling. It is strange that this is working in your tenant.

Hmm, I opted to use api and script editor web part to create our web part

 

Perhaps @Christophe Fiessinger can flag someone down that knows how search indexing + Groups is working.  We havent started using Groups for permissions elsewhere yet, but are definitely planning to and if this is the case, that is a big issue.

 

 

<SCRIPT LANGUAGE='JavaScript' type='text/javascript'>

$(document).ready(function () {

	$.ajax({
		url : "https://mytenant.sharepoint.com/sites/groups/_api/web/lists/getByTitle('my')/Items?$OrderBy=Title",
		contentType : "application/json;odata=verbose",
		headers : { "accept" : "application/json;odata=verbose" },
		success : function onSuccess(data, request){
			if(data.d.results.length == 0){
				$("#listOfGroups").html("No Groups");
			} else {										
				for(i=0;i<data.d.results.length;i++){
					//console.log(data.d.results[i]);
					html = "<B>"+data.d.results[i].Title+"</B><BR>"
					if(data.d.results[i].Conversation){
						html += "<a style='font-size:16px;' title='Group Conversations' href='"+data.d.results[i].Conversation.Url+"' target='_blank'><i class='fa fa-comments-o' aria-hidden='true'></i></a> | ";
					}
					if(data.d.results[i].Calendar){
						html += "<a style='font-size:16px;' title='Group Calendar' href='"+data.d.results[i].Calendar.Url+"' target='_blank'><i class='fa fa-calendar' aria-hidden='true'></i></a> | ";
					}
					if(data.d.results[i].Files){
						html += "<a style='font-size:16px;' title='Group Files' href='"+data.d.results[i].Files.Url+"' target='_blank'><i class='fa fa-folder-open-o' aria-hidden='true'></i></a> | ";
					}
					if(data.d.results[i].Notebook){
						html += "<a style='font-size:16px;' title='Group Notebook' href='"+data.d.results[i].Notebook.Url+"' target='_blank'><i class='fa fa-book' aria-hidden='true'></i></a> | ";
					}
					if(data.d.results[i].Site){
						html += "<a style='font-size:16px;' title='Group SharePoint Site' href='"+data.d.results[i].Site.Url+"' target='_blank'><i class='fa fa-sitemap' aria-hidden='true'></i></a>";
					}
							
				}

				$("#listOfGroups").html(str);
						
			}
							
		},
		error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); }
	});

});

</SCRIPT>

<div id="listOfGroups"></div>

Note, we've got font-awesome embedded for the icons.

 

You could easily test it by

 

1. creating a list

2. add an item, remove all permissions and add assign permissions to an O365 group

3. index the list

4. try to search for the item with a user account given permission through the O365 only on that item

 

We are unable to get the item back

Can confirm - that is pretty ridiculous and needs to be fixed asap

 

Groups not in search.png

Great code! Used it with the combination of Promoted Links. 

Thanks!

Hi @Brent Ellis

 

I am trying to recreate the end-user visual web part based on the script you provided. However, I am not getting anything populated (the API is set, I just can't get the records to display? The Str is not defined? Any insight on this? Any help is appreciated. 

Perhaps my mistake in a poor copy paste, it looks like
$("#listOfGroups").html(str);
should be
$("#listOfGroups").html(html);
in the above example

@Brent Ellis thanks! that fixed it! One more question (please forgive me I am pretty novice at jquery) it doesn't seem to be storing all the groups it's looping through. I am only seeing the last group displayed. Any insight on how to fix this? 

Solved, needed to establish the HTML variable and change the Title Html to html+. Thanks for this work!

My again! Any insight on how to pull in Team conversations or planner URLs? 

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies