Getting the group owner for each Office 365 Group

%3CLINGO-SUB%20id%3D%22lingo-sub-1172038%22%20slang%3D%22en-US%22%3EGetting%20the%20group%20owner%20for%20each%20Office%20365%20Group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1172038%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20a%20minimilst%20approach%20to%20PowerShell%20%2C%20I%20am%20looking%20to%20show%20the%20group%20name%20and%20the%20name(s)%20of%20each%20owner%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EConnect-PnPOnline%20-Scopes%20%22Group.ReadWrite.All%22%2C%22User.Read.All%22%2C%22Directory.Read.All%22%2C%22Sites.Read.All%22%0A%23%20create%20an%20interim%20collection%20whilst%20I%20test%0A%24unifiedGroups%20%3D%20Get-PnPUnifiedGroups%0A%0A%24unifiedGroups%5B3%5D%20%7C%20foreach%20%7B%20%24GroupName%20%3D%20%24_.DisplayName%3B%20%24groupId%20%3D%20%24_.GroupId%3B%20%20%24groupOwner%20%3D%20Get-PnpUnifiedGroupOwners%20-Identity%20%24groupId%20%3B%20Write-Host%20%22%24groupName%20%7C%20%24groupOwner%22%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20almost%20works%20but%20it's%20the%20group%20owner%20that%20is%20stressing%20me%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EMyTestOfficeGroup%20%7C%20OfficeDevPnP.Core.Entities.UnifiedGroupUser%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20need%20resolve%20this%20collection%20for%20each%20group%20and%20or%26nbsp%3B%20rewrite%20the%20snippet%20above%20using%26nbsp%3B%20Select-Object%2C%20to%20replace%20the%20Write-host.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20thing%20I%20have%20noticed%20is%20issues%20displaying%20the%20Site%20Urls.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EDisplayName%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Group%20Id%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%20Site%20URL%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%20%20%20%20%20%20%20%20%20%20%20%20%20%20--------%0AMyTestOfficeGroup%20%20%20%20%20%20%20%20%3F%3F%3F%3F%3F%3F-610f-4639-8a3e-09e6717143ed%20%20%20The%20caller%20does%20not%20have%20permission...%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1172038%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Regular Contributor

 

Using a minimilst approach to PowerShell , I am looking to show the group name and the name(s) of each owner 

 

Connect-PnPOnline -Scopes "Group.ReadWrite.All","User.Read.All","Directory.Read.All","Sites.Read.All"
# create an interim collection whilst I test
$unifiedGroups = Get-PnPUnifiedGroups

$unifiedGroups[3] | foreach { $GroupName = $_.DisplayName; $groupId = $_.GroupId;  $groupOwner = Get-PnpUnifiedGroupOwners -Identity $groupId ; Write-Host "$groupName | $groupOwner" }

 

It almost works but it's the group owner that is stressing me

 

MyTestOfficeGroup | OfficeDevPnP.Core.Entities.UnifiedGroupUser

 

I just need resolve this collection for each group and or  rewrite the snippet above using  Select-Object, to replace the Write-host.

 

One thing I have noticed is issues displaying the Site Urls. 

 

DisplayName                    Group Id                               Site URL
-----------                    --------                               --------
MyTestOfficeGroup        ??????-610f-4639-8a3e-09e6717143ed   The caller does not have permission...

 

 

0 Replies