@@ -29,8 +29,8 @@ namespace SharePointPnP.PowerShell.Commands.Graph
2929 Remarks = "Retrieves a specific Office 365 Group based on its DisplayName" ,
3030 SortOrder = 3 ) ]
3131 [ CmdletExample (
32- Code = "PS:> Get-PnPUnifiedGroup -Identity $groupSiteUrl " ,
33- Remarks = "Retrieves a specific Office 365 Group based on the URL of its Modern SharePoint site " ,
32+ Code = "PS:> Get-PnPUnifiedGroup -Identity $groupSiteMailNickName " ,
33+ Remarks = "Retrieves a specific Office 365 Group based on the mail nickname " ,
3434 SortOrder = 4 ) ]
3535 [ CmdletExample (
3636 Code = "PS:> Get-PnPUnifiedGroup -Identity $group" ,
@@ -41,6 +41,9 @@ public class GetUnifiedGroup : PnPGraphCmdlet
4141 [ Parameter ( Mandatory = false , HelpMessage = "The Identity of the Office 365 Group." ) ]
4242 public UnifiedGroupPipeBind Identity ;
4343
44+ [ Parameter ( Mandatory = false , HelpMessage = "Exclude fetching the site URL for Office 365 Groups. This speeds up large listings." ) ]
45+ public SwitchParameter ExcludeSiteUrl ;
46+
4447 protected override void ExecuteCmdlet ( )
4548 {
4649 UnifiedGroupEntity group = null ;
@@ -51,21 +54,25 @@ protected override void ExecuteCmdlet()
5154 // We have to retrieve a specific group
5255 if ( Identity . Group != null )
5356 {
54- group = UnifiedGroupsUtility . GetUnifiedGroup ( Identity . Group . GroupId , AccessToken ) ;
57+ group = UnifiedGroupsUtility . GetUnifiedGroup ( Identity . Group . GroupId , AccessToken , includeSite : ! ExcludeSiteUrl . IsPresent ) ;
5558 }
5659 else if ( ! String . IsNullOrEmpty ( Identity . DisplayName ) )
5760 {
58- groups = UnifiedGroupsUtility . ListUnifiedGroups ( AccessToken , Identity . DisplayName ) ;
61+ groups = UnifiedGroupsUtility . ListUnifiedGroups ( AccessToken , Identity . DisplayName , includeSite : ! ExcludeSiteUrl . IsPresent ) ;
62+ if ( groups == null || groups . Count == 0 )
63+ {
64+ groups = UnifiedGroupsUtility . ListUnifiedGroups ( AccessToken , mailNickname : Identity . DisplayName , includeSite : ! ExcludeSiteUrl . IsPresent ) ;
65+ }
5966 }
6067 else if ( ! String . IsNullOrEmpty ( Identity . GroupId ) )
6168 {
62- group = UnifiedGroupsUtility . GetUnifiedGroup ( Identity . GroupId , AccessToken ) ;
69+ group = UnifiedGroupsUtility . GetUnifiedGroup ( Identity . GroupId , AccessToken , includeSite : ! ExcludeSiteUrl . IsPresent ) ;
6370 }
6471 }
6572 else
6673 {
6774 // Retrieve all the groups
68- groups = UnifiedGroupsUtility . ListUnifiedGroups ( AccessToken ) ;
75+ groups = UnifiedGroupsUtility . ListUnifiedGroups ( AccessToken , includeSite : ! ExcludeSiteUrl . IsPresent ) ;
6976 }
7077
7178 if ( group != null )
0 commit comments