Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.
Merged

#1621 #1588

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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Added

### Changed
- Fixed Unregister-PnPHubSite where you could not unregister a hub site if the site was deleted before unregistering

### Deprecated

### Contributors

## [2.27.1806.0]
### Added
- Added Grant-PnPTenantServicePrincipalPermission to explicitely grant a permission on a resource for the tenant.
Expand Down
11 changes: 8 additions & 3 deletions Commands/Admin/UnregisterHubSite.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#if !ONPREMISES
using System;
using System.Linq;
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using System.Management.Automation;
using OfficeDevPnP.Core.Sites;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using System;

namespace SharePointPnP.PowerShell.Commands.Admin
{
Expand All @@ -25,7 +25,12 @@ public class UnregisterHubSite : PnPAdminCmdlet

protected override void ExecuteCmdlet()
{
Tenant.UnregisterHubSite(Site.Url);
var hubSitesProperties = Tenant.GetHubSitesProperties();
ClientContext.Load(hubSitesProperties);
ClientContext.ExecuteQueryRetry();
var hubSite = hubSitesProperties.Single(h => h.SiteUrl.Equals(Site.Url, StringComparison.OrdinalIgnoreCase));

Tenant.UnregisterHubSiteById(hubSite.ID);
ClientContext.ExecuteQueryRetry();
}
}
Expand Down