From b7e397be6b0ac2e9c83dd6fd9a14a21cf9d88726 Mon Sep 17 00:00:00 2001 From: KoenZomers Date: Fri, 14 Apr 2023 23:22:45 +0200 Subject: [PATCH 1/2] Added URL validation bypass option --- CHANGELOG.md | 5 +++++ .../Get-PnPSiteCollectionAppCatalog.md | 22 +++++++++++++++---- .../Admin/GetSiteCollectionAppCatalog.cs | 13 ++++++++--- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d746cdbf..54fff00bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `-OutFile` to `Invoke-PnPGraphMethod` which allows for the response to be written to a file [#2971](https://github.com/pnp/powershell/pull/2971) - Added `-OutStream` to `Invoke-PnPGraphMethod` which allows for the response to be written to a memory stream [#2976](https://github.com/pnp/powershell/pull/2976) - Added `-PreviousNode` to `Add-PnPNavigationNode` which allows for adding a navigation node after a specific node [#2940](https://github.com/pnp/powershell/pull/2940) +- Added `-SkipUrlValidation` to `Get-PnPSiteCollectionAppCatalog` which allows for skipping the URL validation when retrieving the site collection app catalog making it faster but potentially returning URLs that have been renamed ### Fixed @@ -21,6 +22,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed issue with `Get-PnPList` cmdlet not working with site-relative URL as identity. [#3005](https://github.com/pnp/powershell/pull/3005) - 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) +### Removed + +- Removed alias `Get-PnPSiteCollectionAppCatalogs` for `Get-PnPSiteCollectionAppCatalog` + ### Contributors - [reusto] diff --git a/documentation/Get-PnPSiteCollectionAppCatalog.md b/documentation/Get-PnPSiteCollectionAppCatalog.md index 49dfed1be..c3e5f9f7c 100644 --- a/documentation/Get-PnPSiteCollectionAppCatalog.md +++ b/documentation/Get-PnPSiteCollectionAppCatalog.md @@ -15,7 +15,7 @@ Returns all site collection scoped app catalogs that exist on the tenant ## SYNTAX ```powershell -Get-PnPSiteCollectionAppCatalog [-CurrentSite ] [-ExcludeDeletedSites ] [-Connection ] [-Verbose] +Get-PnPSiteCollectionAppCatalog [-CurrentSite ] [-ExcludeDeletedSites ] [-SkipUrlValidation ] [-Connection ] [-Verbose] ``` ## DESCRIPTION @@ -43,6 +43,20 @@ Will return all the site collection app catalogs that exist on the tenant exclud ## PARAMETERS +### -Connection +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either 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 +``` + ### -CurrentSite When provided, it will check if the currently connected to site has a site collection App Catalog and will return information on it. If the current site holds no site collection App Catalog, an empty response will be returned. @@ -71,11 +85,11 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Connection -Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. +### -SkipUrlValidation +When provided, the site collection app catalog Urls will not be validated for if they have been renamed since their creation. This makes the cmdlet a lot faster, but it could also lead to URLs being returned that no longer exist. If not provided, for each site collection app catalog, it will look up the actual URL of the site collection app catalog and return that instead of the URL that was used when the site collection app catalog was created. ```yaml -Type: PnPConnection +Type: SwitchParameter Parameter Sets: (All) Required: False diff --git a/src/Commands/Admin/GetSiteCollectionAppCatalog.cs b/src/Commands/Admin/GetSiteCollectionAppCatalog.cs index 639bbb1e3..5fdecd925 100644 --- a/src/Commands/Admin/GetSiteCollectionAppCatalog.cs +++ b/src/Commands/Admin/GetSiteCollectionAppCatalog.cs @@ -1,5 +1,4 @@ using Microsoft.SharePoint.Client; -using PnP.PowerShell.Commands.Attributes; using PnP.PowerShell.Commands.Base; using PnP.PowerShell.Commands.Model.SharePoint; using System; @@ -10,8 +9,6 @@ namespace PnP.PowerShell.Commands { [Cmdlet(VerbsCommon.Get, "PnPSiteCollectionAppCatalog")] - [Alias("Get-PnPSiteCollectionAppCatalogs")] - [WriteAliasWarning("Please use 'Get-PnPSiteCollectionAppCatalog' (singular). The alias 'Get-PnPSiteCollectionAppCatalogs' (plural) will be removed in a future release.")] [OutputType(typeof(IEnumerable))] public class GetSiteCollectionAppCatalog : PnPAdminCmdlet { @@ -21,6 +18,9 @@ public class GetSiteCollectionAppCatalog : PnPAdminCmdlet [Parameter(Mandatory = false)] public SwitchParameter CurrentSite; + [Parameter(Mandatory = false)] + public SwitchParameter SkipUrlValidation; + protected override void ExecuteCmdlet() { WriteVerbose("Retrieving all site collection App Catalogs from SharePoint Online"); @@ -58,6 +58,13 @@ protected override void ExecuteCmdlet() appCatalogsLocalModel.Add(currentSite); } + if(SkipUrlValidation.ToBool()) + { + WriteVerbose($"Skipping URL validation since the {nameof(SkipUrlValidation)} flag has been provided"); + WriteObject(appCatalogsLocalModel, true); + return; + } + var results = new List(appCatalogsLocalModel.Count); foreach (var appCatalogLocalModel in appCatalogsLocalModel) { From f2f528fe708f753de0f7ac08f983631b5c97df33 Mon Sep 17 00:00:00 2001 From: KoenZomers Date: Fri, 14 Apr 2023 23:26:16 +0200 Subject: [PATCH 2/2] Adding PR reference --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54fff00bb..622436706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `-OutFile` to `Invoke-PnPGraphMethod` which allows for the response to be written to a file [#2971](https://github.com/pnp/powershell/pull/2971) - Added `-OutStream` to `Invoke-PnPGraphMethod` which allows for the response to be written to a memory stream [#2976](https://github.com/pnp/powershell/pull/2976) - Added `-PreviousNode` to `Add-PnPNavigationNode` which allows for adding a navigation node after a specific node [#2940](https://github.com/pnp/powershell/pull/2940) -- Added `-SkipUrlValidation` to `Get-PnPSiteCollectionAppCatalog` which allows for skipping the URL validation when retrieving the site collection app catalog making it faster but potentially returning URLs that have been renamed +- Added `-SkipUrlValidation` to `Get-PnPSiteCollectionAppCatalog` which allows for skipping the URL validation when retrieving the site collection app catalog making it faster but potentially returning URLs that have been renamed [#2305](https://github.com/pnp/powershell/pull/3025) ### Fixed @@ -24,7 +24,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed -- Removed alias `Get-PnPSiteCollectionAppCatalogs` for `Get-PnPSiteCollectionAppCatalog` +- Removed alias `Get-PnPSiteCollectionAppCatalogs` for `Get-PnPSiteCollectionAppCatalog` [#2305](https://github.com/pnp/powershell/pull/3025) ### Contributors