Skip to content

Commit fe8c789

Browse files
authored
Add ClearGroupId parameter to Set-PnPSite and Set-PnPTenantSite cmdlets to remove assigned Microsoft 365 group ID (#5192)
* Add ClearGroupId parameter to Set-PnPSite and Set-PnPTenantSite cmdlets to remove assigned Microsoft 365 group ID * Add support for -ClearGroupId parameter in Set-PnPSite and Set-PnPTenantSite cmdlets
1 parent d12a398 commit fe8c789

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2525
- Added `Import-PnPFlow` cmdlet to import Power Automate in the tenant. [#4854](https://github.com/pnp/powershell/pull/4854)
2626
- Marked `-Force` as obsolete within Enable-PnPFeature cmdlet . [#5146](https://github.com/pnp/powershell/pull/5146)
2727
- Added `Remove-PnPPowerAppPermission` cmdlet to remove Power Apps permissions. [#5168](https://github.com/pnp/powershell/pull/5168)
28+
- Added support for `-ClearGroupId` parameter in `Set-PnPSite` and `Set-PnPTenantSite` cmdlets. [#5192](https://github.com/pnp/powershell/pull/5192)
2829

2930
### Changed
3031
- Improved `Get-PnPTerm` cmdlet to show a better error message. [#4933](https://github.com/pnp/powershell/pull/4933)

documentation/Set-PnPSite.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Set-PnPSite
5252
[-ListsShowHeaderAndNavigation <Boolean>]
5353
[-RestrictContentOrgWideSearch <Boolean>]
5454
[-CanSyncHubSitePermissions <SwitchParameter>]
55+
[-ClearGroupId]
5556
[-HidePeoplePreviewingFiles <Boolean>]
5657
[-HidePeopleWhoHaveListsOpen <Boolean>]
5758
[-RestrictedAccessControl <Boolean>]
@@ -693,6 +694,20 @@ Accept pipeline input: False
693694
Accept wildcard characters: False
694695
```
695696
697+
### -ClearGroupId
698+
This parameter allows you to remove the assigned Microsoft 365 group ID on a site, when the group is permanently deleted.
699+
700+
```yaml
701+
Type: Switch Parameter
702+
Parameter Sets: Set Properties
703+
704+
Required: False
705+
Position: Named
706+
Default value: None
707+
Accept pipeline input: False
708+
Accept wildcard characters: False
709+
```
710+
696711
### -Wait
697712
Wait for the operation to complete
698713

documentation/Set-PnPTenantSite.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Set-PnPTenantSite [-Identity] <String> [-Title <String>] [-LocaleId <UInt32>] [-
4646
[-RestrictedAccessControl <Boolean>] [-ClearRestrictedAccessControl <SwitchParameter>] [-RestrictedAccessControlGroups <Guid[]>]
4747
[-AddRestrictedAccessControlGroups <Guid[]>] [-RemoveRestrictedAccessControlGroups <Guid[]>][-InheritVersionPolicyFromTenant <SwitchParameter>]
4848
[-AllowWebPropertyBagUpdateWhenDenyAddAndCustomizePagesIsEnabled <Boolean>]
49+
[-ClearGroupId]
4950
[-Wait]
5051
[-Connection <PnPConnection>]
5152
```
@@ -816,6 +817,20 @@ Accept pipeline input: False
816817
Accept wildcard characters: False
817818
```
818819

820+
### -ClearGroupId
821+
This parameter allows you to remove the assigned Microsoft 365 group ID on a site, when the group is permanently deleted.
822+
823+
```yaml
824+
Type: Switch Parameter
825+
Parameter Sets: Set Properties
826+
827+
Required: False
828+
Position: Named
829+
Default value: None
830+
Accept pipeline input: False
831+
Accept wildcard characters: False
832+
```
833+
819834
### -RemoveRestrictedAccessControlGroups
820835
You can remove the specified security group from restricted access control configuration. Members of the security group are no longer be able to access site content while the policy is enforced on the site.
821836

src/Commands/Admin/SetTenantSite.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ public class SetTenantSite : PnPSharePointOnlineAdminCmdlet
232232
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)]
233233
public SwitchParameter ReadOnlyForBlockDownloadPolicy;
234234

235+
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)]
236+
public SwitchParameter ClearGroupId;
237+
235238
[Parameter(Mandatory = false)]
236239
public SwitchParameter Wait;
237240

@@ -695,6 +698,12 @@ private void SetSiteProperties(Func<TenantOperationMessage, bool> timeoutFunctio
695698
updateRequired = true;
696699
}
697700

701+
if (ParameterSpecified(nameof(ClearGroupId)))
702+
{
703+
props.ClearGroupId = ClearGroupId;
704+
updateRequired = true;
705+
}
706+
698707
if (updateRequired)
699708
{
700709
var op = props.Update();

src/Commands/Site/SetSite.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public class SetSite : PnPSharePointCmdlet
140140
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)]
141141
public SwitchParameter ReadOnlyForBlockDownloadPolicy;
142142

143+
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)]
144+
public SwitchParameter ClearGroupId;
145+
143146
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_LOCKSTATE)]
144147
public SwitchParameter Wait;
145148

@@ -458,6 +461,12 @@ protected override void ExecuteCmdlet()
458461
executeQueryRequired = true;
459462
}
460463

464+
if (ParameterSpecified(nameof(ClearGroupId)) && ClearGroupId.IsPresent)
465+
{
466+
siteProperties.ClearGroupId = ClearGroupId.ToBool();
467+
executeQueryRequired = true;
468+
}
469+
461470
if (executeQueryRequired)
462471
{
463472
siteProperties.Update();
@@ -515,8 +524,9 @@ private bool IsTenantProperty() =>
515524
ParameterSpecified(nameof(ExcludedBlockDownloadGroupIds)) ||
516525
ListsShowHeaderAndNavigation.HasValue ||
517526
HidePeoplePreviewingFiles.HasValue ||
518-
HidePeopleWhoHaveListsOpen.HasValue ||
519-
ParameterSpecified(nameof(ExcludeBlockDownloadSharePointGroups)) ||
520-
ReadOnlyForBlockDownloadPolicy.IsPresent;
527+
HidePeopleWhoHaveListsOpen.HasValue ||
528+
ParameterSpecified(nameof(ExcludeBlockDownloadSharePointGroups)) ||
529+
ReadOnlyForBlockDownloadPolicy.IsPresent ||
530+
ClearGroupId.IsPresent;
521531
}
522532
}

0 commit comments

Comments
 (0)