From 4ced4f5bbb471032d87032fb660071ee544f87a3 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Fri, 3 Jul 2026 23:40:38 +0300 Subject: [PATCH 1/2] Add Get-PnPGeoAdministrator cmdlet Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 1 + documentation/Get-PnPGeoAdministrator.md | 59 +++++++++++++++++++ src/Commands/Admin/GetGeoAdministrator.cs | 21 +++++++ src/Commands/Enums/GroupMemberType.cs | 23 ++++++++ src/Commands/Model/GeoAdministrator.cs | 36 +++++++++++ .../Model/GeoAdministratorCollection.cs | 13 ++++ .../MultiGeo/MultiGeoRestApiClient.cs | 18 ++++++ 7 files changed, 171 insertions(+) create mode 100644 documentation/Get-PnPGeoAdministrator.md create mode 100644 src/Commands/Admin/GetGeoAdministrator.cs create mode 100644 src/Commands/Enums/GroupMemberType.cs create mode 100644 src/Commands/Model/GeoAdministrator.cs create mode 100644 src/Commands/Model/GeoAdministratorCollection.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 662b65f95..f49b3b8b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [Current nightly] ### Added +- Added `Get-PnPGeoAdministrator` cmdlet to retrieve SharePoint Online geo administrators. - Added `Get-PnPMultiGeoExperience` cmdlet to retrieve the SharePoint Online multi-geo experience mode. [#5372](https://github.com/pnp/powershell/pull/5372) - Added `Set-PnPMultiGeoExperience` cmdlet to upgrade the tenant multi-geo experience to include SharePoint Online Multi-Geo. [#5369](https://github.com/pnp/powershell/pull/5369) - Added `Set-PnPMultiGeoCompanyAllowedDataLocation` cmdlet to start setting up a SharePoint Online multi-geo allowed data location. [#5368](https://github.com/pnp/powershell/pull/5368) diff --git a/documentation/Get-PnPGeoAdministrator.md b/documentation/Get-PnPGeoAdministrator.md new file mode 100644 index 000000000..e8cd6f010 --- /dev/null +++ b/documentation/Get-PnPGeoAdministrator.md @@ -0,0 +1,59 @@ +--- +Module Name: PnP.PowerShell +title: Get-PnPGeoAdministrator +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPGeoAdministrator.html +--- + +# Get-PnPGeoAdministrator + +## SYNOPSIS +Returns SharePoint Online geo administrators. + +## SYNTAX + +```powershell +Get-PnPGeoAdministrator [-Connection ] +``` + +## DESCRIPTION +Returns the SharePoint Online geo administrators configured for the tenant. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +Get-PnPGeoAdministrator +``` + +Returns all SharePoint Online geo administrators. + +## PARAMETERS + +### -Connection +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by specifying `-ReturnConnection` on `Connect-PnPOnline` or by executing `Get-PnPConnection`. + +```yaml +Type: PnPConnection +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## OUTPUTS + +### PnP.PowerShell.Commands.Model.GeoAdministrator +Returns objects with `DisplayName`, `LoginName`, `MemberType`, `ObjectId`, and `GeoLocation` properties. + +## RELATED LINKS + +[Get-PnPMultiGeoCompanyAllowedDataLocation](Get-PnPMultiGeoCompanyAllowedDataLocation.md) + +[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) diff --git a/src/Commands/Admin/GetGeoAdministrator.cs b/src/Commands/Admin/GetGeoAdministrator.cs new file mode 100644 index 000000000..2ba35596d --- /dev/null +++ b/src/Commands/Admin/GetGeoAdministrator.cs @@ -0,0 +1,21 @@ +using PnP.PowerShell.Commands.Attributes; +using PnP.PowerShell.Commands.Base; +using PnP.PowerShell.Commands.Model; +using PnP.PowerShell.Commands.Utilities.MultiGeo; +using System.Management.Automation; + +namespace PnP.PowerShell.Commands.Admin +{ + [Cmdlet(VerbsCommon.Get, "PnPGeoAdministrator")] + [RequiredApiApplicationPermissions("sharepoint/Sites.FullControl.All")] + [RequiredApiDelegatedPermissions("sharepoint/AllSites.FullControl")] + [OutputType(typeof(GeoAdministrator))] + public class GetGeoAdministrator : PnPSharePointOnlineAdminCmdlet + { + protected override void ExecuteCmdlet() + { + var multiGeoRestApiClient = new MultiGeoRestApiClient(AdminContext); + WriteObject(multiGeoRestApiClient.GetGeoAdministrators().GeoAdministrators, true); + } + } +} diff --git a/src/Commands/Enums/GroupMemberType.cs b/src/Commands/Enums/GroupMemberType.cs new file mode 100644 index 000000000..4402952c0 --- /dev/null +++ b/src/Commands/Enums/GroupMemberType.cs @@ -0,0 +1,23 @@ +namespace PnP.PowerShell.Commands.Enums +{ + /// + /// Specifies the member type for a SharePoint Online geo administrator. + /// + public enum GroupMemberType + { + /// + /// The member type is unknown. + /// + Unknown = 0, + + /// + /// The member is a user. + /// + User = 1, + + /// + /// The member is a group. + /// + Group = 2 + } +} diff --git a/src/Commands/Model/GeoAdministrator.cs b/src/Commands/Model/GeoAdministrator.cs new file mode 100644 index 000000000..b396054ce --- /dev/null +++ b/src/Commands/Model/GeoAdministrator.cs @@ -0,0 +1,36 @@ +using PnP.PowerShell.Commands.Enums; +using System; + +namespace PnP.PowerShell.Commands.Model +{ + /// + /// Contains a SharePoint Online geo administrator. + /// + public class GeoAdministrator + { + /// + /// The display name of the geo administrator. + /// + public string DisplayName { get; set; } + + /// + /// The login name of the geo administrator. + /// + public string LoginName { get; set; } + + /// + /// The member type of the geo administrator. + /// + public GroupMemberType MemberType { get; set; } + + /// + /// The object identifier of the geo administrator. + /// + public Guid ObjectId { get; set; } + + /// + /// The geo location administered by the geo administrator. + /// + public string GeoLocation { get; set; } + } +} diff --git a/src/Commands/Model/GeoAdministratorCollection.cs b/src/Commands/Model/GeoAdministratorCollection.cs new file mode 100644 index 000000000..ca3ecffd9 --- /dev/null +++ b/src/Commands/Model/GeoAdministratorCollection.cs @@ -0,0 +1,13 @@ +namespace PnP.PowerShell.Commands.Model +{ + /// + /// Contains SharePoint Online geo administrators returned by the multi-geo REST API. + /// + internal class GeoAdministratorCollection + { + /// + /// The SharePoint Online geo administrators. + /// + public GeoAdministrator[] GeoAdministrators { get; set; } + } +} diff --git a/src/Commands/Utilities/MultiGeo/MultiGeoRestApiClient.cs b/src/Commands/Utilities/MultiGeo/MultiGeoRestApiClient.cs index c703e7fea..f696f33b5 100644 --- a/src/Commands/Utilities/MultiGeo/MultiGeoRestApiClient.cs +++ b/src/Commands/Utilities/MultiGeo/MultiGeoRestApiClient.cs @@ -31,6 +31,8 @@ internal class MultiGeoRestApiClient private const string TenantRenameJobsPathToCancelAJob = "TenantRenameJobs/Cancel"; private const string GeoMoveCompatibilityChecksMinimumApiVersion = "1.3.6"; private const string GeoMoveCompatibilityChecksPath = "GeoMoveCompatibilityChecks"; + private const string GeoAdministratorsMinimumApiVersion = "1.2-beta"; + private const string GeoAdministratorsPath = "GeoAdministrators"; private const string GeoExperienceMinimumApiVersion = "1.3.7"; private const string GeoExperiencePath = "GeoExperience"; private const string UpdateGeoExperienceModePath = "GeoExperience/UpgradeToSPOMode"; @@ -158,6 +160,11 @@ internal IEnumerable GetGeoMoveCompatibilityChe return GetFeed(GeoMoveCompatibilityChecksPath, GetCurrentApiVersion(GeoMoveCompatibilityChecksMinimumApiVersion)); } + internal GeoAdministratorCollection GetGeoAdministrators() + { + return Get(GeoAdministratorsPath, GetGeoAdministratorsApiVersion()); + } + internal MultiGeoExperience GetGeoExperience() { return Get(GeoExperiencePath, GetGeoExperienceApiVersion()); @@ -539,6 +546,17 @@ private string GetStorageQuotasApiVersion() return apiVersion; } + private string GetGeoAdministratorsApiVersion() + { + var apiVersion = GetCurrentApiVersion(); + if (!IsSupportedApiVersion(apiVersion, GeoAdministratorsMinimumApiVersion)) + { + throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, CommandResources.CrossGeoInvalidVersion, GetApplicationVersion())); + } + + return apiVersion; + } + private string GetGeoExperienceApiVersion() { var apiVersion = GetCurrentApiVersion(); From 7b8714c6d9acc754db21ca1deee4ce0c4c88fcba Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Fri, 3 Jul 2026 23:52:17 +0300 Subject: [PATCH 2/2] Link Get-PnPGeoAdministrator changelog entry Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f49b3b8b5..62963bd4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [Current nightly] ### Added -- Added `Get-PnPGeoAdministrator` cmdlet to retrieve SharePoint Online geo administrators. +- Added `Get-PnPGeoAdministrator` cmdlet to retrieve SharePoint Online geo administrators. [#5378](https://github.com/pnp/powershell/pull/5378) - Added `Get-PnPMultiGeoExperience` cmdlet to retrieve the SharePoint Online multi-geo experience mode. [#5372](https://github.com/pnp/powershell/pull/5372) - Added `Set-PnPMultiGeoExperience` cmdlet to upgrade the tenant multi-geo experience to include SharePoint Online Multi-Geo. [#5369](https://github.com/pnp/powershell/pull/5369) - Added `Set-PnPMultiGeoCompanyAllowedDataLocation` cmdlet to start setting up a SharePoint Online multi-geo allowed data location. [#5368](https://github.com/pnp/powershell/pull/5368)