Skip to content
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

Added URL validation bypass option to Get-PnPSiteCollectionAppCatalog #3025

Merged
merged 3 commits into from
Apr 22, 2023
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [#2305](https://github.com/pnp/powershell/pull/3025)

### Fixed

Expand All @@ -23,6 +24,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed regressions within the following cmdlets `Get-PnPTenantCdnEnabled`, `Get-PnPTenantCdnOrigin`, `Get-PnPTenantCdnPolicies`, `Get-PnPTenantDeletedSite`, `Get-PnPTenantInstance` [#3030](https://github.com/pnp/powershell/pull/3030)
- Fixed issue where `Add-PnPSiteCollectionAdmin -PrimarySiteCollectionAdmin <user>` would require owners to be specified as well. [#3035](https://github.com/pnp/powershell/pull/3035)

### Removed

- Removed alias `Get-PnPSiteCollectionAppCatalogs` for `Get-PnPSiteCollectionAppCatalog` [#2305](https://github.com/pnp/powershell/pull/3025)

### Contributors

- [reusto]
Expand Down
22 changes: 18 additions & 4 deletions documentation/Get-PnPSiteCollectionAppCatalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Returns all site collection scoped app catalogs that exist on the tenant
## SYNTAX

```powershell
Get-PnPSiteCollectionAppCatalog [-CurrentSite <SwitchParameter>] [-ExcludeDeletedSites <SwitchParameter>] [-Connection <PnPConnection>] [-Verbose]
Get-PnPSiteCollectionAppCatalog [-CurrentSite <SwitchParameter>] [-ExcludeDeletedSites <SwitchParameter>] [-SkipUrlValidation <SwitchParameter>] [-Connection <PnPConnection>] [-Verbose]
```

## DESCRIPTION
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions src/Commands/Admin/GetSiteCollectionAppCatalog.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<SiteCollectionAppCatalog>))]
public class GetSiteCollectionAppCatalog : PnPAdminCmdlet
{
Expand All @@ -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");
Expand Down Expand Up @@ -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<SiteCollectionAppCatalog>(appCatalogsLocalModel.Count);
foreach (var appCatalogLocalModel in appCatalogsLocalModel)
{
Expand Down