Skip to content

Commit 894f30f

Browse files
authored
Merge pull request #3030 from KoenZomers/AdminContextRegression
Fixing PnPAdminCmdlet regressions
2 parents f88181c + 8619e0f commit 894f30f

File tree

7 files changed

+15
-23
lines changed

7 files changed

+15
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2020
- Fixed issue with `Grant-PnPAzureADAppSitePermission` cmdlet where users are not able to set selected site in the `Sites.Selected` permission. [#2983](https://github.com/pnp/powershell/pull/2983)
2121
- Fixed issue with `Get-PnPList` cmdlet not working with site-relative URL as identity. [#3005](https://github.com/pnp/powershell/pull/3005)
2222
- Fixed issue with `Add-PnPNavigationNode` cmdlet where the target audience would not correctly be set when creating a node as a child of a parent node [#2940](https://github.com/pnp/powershell/pull/2940)
23-
- Fixed issue where `Add-PnPSiteCollectionAdmin -PrimarySiteCollectionAdmin <user>` would require owners to be specified as well
23+
- Fixed regressions within the following cmdlets `Get-PnPTenantCdnEnabled`, `Get-PnPTenantCdnOrigin`, `Get-PnPTenantCdnPolicies`, `Get-PnPTenantDeletedSite`, `Get-PnPTenantInstance` [#3030](https://github.com/pnp/powershell/pull/3030)
24+
- Fixed issue where `Add-PnPSiteCollectionAdmin -PrimarySiteCollectionAdmin <user>` would require owners to be specified as well. [#3035](https://github.com/pnp/powershell/pull/3035)
2425

2526
### Contributors
2627

src/Commands/Admin/GetTenantAppCatalogUrl.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Management.Automation;
22
using Microsoft.SharePoint.Client;
33

4-
54
namespace PnP.PowerShell.Commands
65
{
76
[Cmdlet(VerbsCommon.Get, "PnPTenantAppCatalogUrl")]

src/Commands/Admin/GetTenantCdnEnabled.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Microsoft.Online.SharePoint.TenantAdministration;
22
using Microsoft.SharePoint.Client;
3-
43
using PnP.PowerShell.Commands.Base;
54
using System.Management.Automation;
65

@@ -15,7 +14,7 @@ public class GetTenantCdnEnabled : PnPAdminCmdlet
1514
protected override void ExecuteCmdlet()
1615
{
1716
var result = Tenant.GetTenantCdnEnabled(CdnType);
18-
ClientContext.ExecuteQueryRetry();
17+
AdminContext.ExecuteQueryRetry();
1918
WriteObject(result);
2019
}
2120
}

src/Commands/Admin/GetTenantCdnOrigin.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Microsoft.Online.SharePoint.TenantAdministration;
22
using Microsoft.SharePoint.Client;
3-
43
using PnP.PowerShell.Commands.Base;
54
using System.Management.Automation;
65

@@ -15,7 +14,7 @@ public class GetTenantCdnOrigin : PnPAdminCmdlet
1514
protected override void ExecuteCmdlet()
1615
{
1716
var origins = Tenant.GetTenantCdnOrigins(CdnType);
18-
ClientContext.ExecuteQueryRetry();
17+
AdminContext.ExecuteQueryRetry();
1918
WriteObject(origins, true);
2019
}
2120
}

src/Commands/Admin/GetTenantCdnPolicies.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
using Microsoft.Online.SharePoint.TenantAdministration;
22
using Microsoft.SharePoint.Client;
3-
43
using PnP.PowerShell.Commands.Base;
54
using System.Management.Automation;
6-
using PnP.Framework.Sites;
7-
using PnP.PowerShell.Commands.Base.PipeBinds;
85
using System;
9-
using PnP.PowerShell.Commands.Enums;
106
using System.Collections.Generic;
117

128
namespace PnP.PowerShell.Commands.Admin
@@ -20,7 +16,7 @@ public class GetTenantCdnPolicies : PnPAdminCmdlet
2016
protected override void ExecuteCmdlet()
2117
{
2218
var result = Tenant.GetTenantCdnPolicies(CdnType);
23-
ClientContext.ExecuteQueryRetry();
19+
AdminContext.ExecuteQueryRetry();
2420

2521
WriteObject(Parse(result),true);
2622
}

src/Commands/Admin/GetTenantDeletedSite.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ protected override void ExecuteCmdlet()
6262
else
6363
{
6464
DeletedSiteProperties deletedSitePropertiesByUrl = Tenant.GetDeletedSitePropertiesByUrl(Identity.Url);
65-
ClientContext.Load(deletedSitePropertiesByUrl);
65+
AdminContext.Load(deletedSitePropertiesByUrl);
6666

6767
try
6868
{
69-
ClientContext.ExecuteQueryRetry();
69+
AdminContext.ExecuteQueryRetry();
7070
WriteObject(new Model.SPODeletedSite(deletedSitePropertiesByUrl));
7171
}
7272
catch (Microsoft.SharePoint.Client.ServerException e) when (e.ServerErrorTypeName.Equals("Microsoft.SharePoint.Client.UnknownError", StringComparison.InvariantCultureIgnoreCase))
@@ -90,9 +90,9 @@ private bool RequestDeletedSitePropertiesFromSharePoint(Func<string, SPODeletedS
9090
{
9191
throw new ArgumentNullException("Something went wrong fetching deleted sites");
9292
}
93-
ClientContext.Load(spoDeletedSitePropertiesEnumerable);
94-
ClientContext.Load(spoDeletedSitePropertiesEnumerable, (SPODeletedSitePropertiesEnumerable sp) => sp.NextStartIndexFromSharePoint);
95-
ClientContext.ExecuteQueryRetry();
93+
AdminContext.Load(spoDeletedSitePropertiesEnumerable);
94+
AdminContext.Load(spoDeletedSitePropertiesEnumerable, (SPODeletedSitePropertiesEnumerable sp) => sp.NextStartIndexFromSharePoint);
95+
AdminContext.ExecuteQueryRetry();
9696
if (siteRowLimit == 0 || spoDeletedSitePropertiesEnumerable.Count <= siteRowLimit)
9797
{
9898
deletedSitePropertiesList.AddRange(spoDeletedSitePropertiesEnumerable);
@@ -134,9 +134,9 @@ private bool RequestDeletedSiteProperties(Func<int, SPODeletedSitePropertiesEnum
134134
while (num >= 0 && flag2)
135135
{
136136
SPODeletedSitePropertiesEnumerable spoDeletedSitePropertiesEnumerable = getDeletedSitePropertiesFunc(num);
137-
ClientContext.Load(spoDeletedSitePropertiesEnumerable);
138-
ClientContext.Load(spoDeletedSitePropertiesEnumerable, (SPODeletedSitePropertiesEnumerable sp) => sp.NextStartIndex);
139-
ClientContext.ExecuteQueryRetry();
137+
AdminContext.Load(spoDeletedSitePropertiesEnumerable);
138+
AdminContext.Load(spoDeletedSitePropertiesEnumerable, (SPODeletedSitePropertiesEnumerable sp) => sp.NextStartIndex);
139+
AdminContext.ExecuteQueryRetry();
140140
if (spoDeletedSitePropertiesEnumerable == null)
141141
{
142142
throw new ArgumentNullException("Something went wrong fetching deleted sites");

src/Commands/Admin/GetTenantInstance.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using Microsoft.SharePoint.Client;
2-
32
using PnP.PowerShell.Commands.Base;
4-
using PnP.PowerShell.Commands.Base.PipeBinds;
53
using System.Linq;
64
using System.Management.Automation;
75

@@ -13,8 +11,8 @@ public class GetTenantInstance : PnPAdminCmdlet
1311
protected override void ExecuteCmdlet()
1412
{
1513
var instances = Tenant.GetTenantInstances();
16-
ClientContext.Load(instances);
17-
ClientContext.ExecuteQueryRetry();
14+
AdminContext.Load(instances);
15+
AdminContext.ExecuteQueryRetry();
1816
WriteObject(instances.Select(i => Model.TenantInstance.Convert(i)));
1917
}
2018
}

0 commit comments

Comments
 (0)