From 3d6072f99dd2530f04c12852c056053d1d99aec5 Mon Sep 17 00:00:00 2001 From: Nishkalank Bezawada <47456098+NishkalankBezawada@users.noreply.github.com> Date: Tue, 29 Oct 2024 20:22:02 +0100 Subject: [PATCH] Add warning to Get-PnPTenantInfo about required permissions (#4473) * Add warning to Get-PnPTenantInfo about required permissions * Updated Get-PnPTenantInfo documentation with Required Permissions * Corrected the pull request build error * Changed the required permissions attribute to use Delegated or Application Permissions --------- Co-authored-by: Gautam Sheth --- documentation/Get-PnPTenantInfo.md | 3 +++ src/Commands/Admin/GetTenantInfo.cs | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/documentation/Get-PnPTenantInfo.md b/documentation/Get-PnPTenantInfo.md index dcdb9dbd5..62bb1a653 100644 --- a/documentation/Get-PnPTenantInfo.md +++ b/documentation/Get-PnPTenantInfo.md @@ -12,6 +12,9 @@ online version: https://pnp.github.io/powershell/cmdlets/Get-PnPTenantInfo.html ## SYNOPSIS Gets information about any tenant +** Required Permissions ** +Graph: CrossTenantInformation.ReadBasic.All + ## SYNTAX ### Current Tenant (default) diff --git a/src/Commands/Admin/GetTenantInfo.cs b/src/Commands/Admin/GetTenantInfo.cs index fd60a6ce0..d9ae9e6c3 100644 --- a/src/Commands/Admin/GetTenantInfo.cs +++ b/src/Commands/Admin/GetTenantInfo.cs @@ -1,4 +1,5 @@ using Microsoft.SharePoint.Client; +using PnP.PowerShell.Commands.Attributes; using PnP.PowerShell.Commands.Base; using PnP.PowerShell.Commands.Utilities.REST; using System; @@ -7,6 +8,7 @@ namespace PnP.PowerShell.Commands.Admin { [Cmdlet(VerbsCommon.Get, "PnPTenantInfo")] + [RequiredApiDelegatedOrApplicationPermissions("graph/CrossTenantInformation.ReadBasic.All")] [OutputType(typeof(Model.TenantInfo))] public class GetTenantInfo : PnPAdminCmdlet { @@ -35,13 +37,13 @@ protected override void ExecuteCmdlet() var requestUrl = BuildRequestUrl(); WriteVerbose($"Making call to {requestUrl} to request tenant information"); - var results = RestHelper.Get(Connection.HttpClient, requestUrl, graphAccessToken); + var results = GraphHelper.Get(this, Connection, requestUrl, graphAccessToken); WriteObject(results, true); } private string BuildRequestUrl() { - var baseUrl = $"https://{Connection.GraphEndPoint}/v1.0/tenantRelationships/"; + var baseUrl = $"/v1.0/tenantRelationships/"; var query = string.Empty; switch (ParameterSetName) {