Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. [#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)
Expand Down
59 changes: 59 additions & 0 deletions documentation/Get-PnPGeoAdministrator.md
Original file line number Diff line number Diff line change
@@ -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 <PnPConnection>]
```

## 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)
21 changes: 21 additions & 0 deletions src/Commands/Admin/GetGeoAdministrator.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
23 changes: 23 additions & 0 deletions src/Commands/Enums/GroupMemberType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace PnP.PowerShell.Commands.Enums
{
/// <summary>
/// Specifies the member type for a SharePoint Online geo administrator.
/// </summary>
public enum GroupMemberType
{
/// <summary>
/// The member type is unknown.
/// </summary>
Unknown = 0,

/// <summary>
/// The member is a user.
/// </summary>
User = 1,

/// <summary>
/// The member is a group.
/// </summary>
Group = 2
}
}
36 changes: 36 additions & 0 deletions src/Commands/Model/GeoAdministrator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using PnP.PowerShell.Commands.Enums;
using System;

namespace PnP.PowerShell.Commands.Model
{
/// <summary>
/// Contains a SharePoint Online geo administrator.
/// </summary>
public class GeoAdministrator
{
/// <summary>
/// The display name of the geo administrator.
/// </summary>
public string DisplayName { get; set; }

/// <summary>
/// The login name of the geo administrator.
/// </summary>
public string LoginName { get; set; }

/// <summary>
/// The member type of the geo administrator.
/// </summary>
public GroupMemberType MemberType { get; set; }

/// <summary>
/// The object identifier of the geo administrator.
/// </summary>
public Guid ObjectId { get; set; }

/// <summary>
/// The geo location administered by the geo administrator.
/// </summary>
public string GeoLocation { get; set; }
}
}
13 changes: 13 additions & 0 deletions src/Commands/Model/GeoAdministratorCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace PnP.PowerShell.Commands.Model
{
/// <summary>
/// Contains SharePoint Online geo administrators returned by the multi-geo REST API.
/// </summary>
internal class GeoAdministratorCollection
{
/// <summary>
/// The SharePoint Online geo administrators.
/// </summary>
public GeoAdministrator[] GeoAdministrators { get; set; }
}
}
18 changes: 18 additions & 0 deletions src/Commands/Utilities/MultiGeo/MultiGeoRestApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -158,6 +160,11 @@ internal IEnumerable<GeoMoveTenantCompatibilityCheck> GetGeoMoveCompatibilityChe
return GetFeed<GeoMoveTenantCompatibilityCheck>(GeoMoveCompatibilityChecksPath, GetCurrentApiVersion(GeoMoveCompatibilityChecksMinimumApiVersion));
}

internal GeoAdministratorCollection GetGeoAdministrators()
{
return Get<GeoAdministratorCollection>(GeoAdministratorsPath, GetGeoAdministratorsApiVersion());
}

internal MultiGeoExperience GetGeoExperience()
{
return Get<MultiGeoExperience>(GeoExperiencePath, GetGeoExperienceApiVersion());
Expand Down Expand Up @@ -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;
}
Comment on lines +549 to +558

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as-is intentionally for SPO Management Shell parity. The decompiled GetSPOGeoAdministrator/MultiGeoRestApiClient.GetGeoAdministrators path checks support against V12Beta/1.2-beta and throws CrossGeoInvalidVersion with the application version. Using GetCurrentApiVersion(minimumApiVersion) would change the error text/behavior, which this PR is trying to match exactly.


private string GetGeoExperienceApiVersion()
{
var apiVersion = GetCurrentApiVersion();
Expand Down
Loading