-
Notifications
You must be signed in to change notification settings - Fork 409
Add Get-PnPGeoAdministrator cmdlet #5378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.