-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #704 from a1mery/spo-remove-access-requests
New script sample to remove site access requests
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
plugin: add-to-gallery | ||
--- | ||
|
||
# Remove site access requests | ||
|
||
## Summary | ||
|
||
Sometimes, as a site owner you cannot manage all site access requests for your site. Especially when users request access for specific content on the site (Site page, list etc.) you might prefer to grant access to the entire site. | ||
Use this script to remove site access requests depending on their status. | ||
|
||
![Example Screenshot](assets/example.png) | ||
|
||
|
||
# [PnP PowerShell](#tab/pnpps) | ||
|
||
```powershell | ||
$siteUrl = "https://contoso.sharepoint.com/sites/DemoSite" | ||
# Request status: 0 - Pending, 1 - Accepted, 3 - Declined | ||
$requestStatus = 0 | ||
Connect-PnPOnline -Url $siteUrl -Interactive | ||
$batch = New-PnPBatch | ||
$accessRequestsList = Get-PnPList | Where-Object {$_.Title -eq "Access Requests"} | ||
$itemsToRemove = Get-PnPListItem -List $accessRequestsList -Query "<View><Query><Where><And><Eq><FieldRef Name='Status'/><Value Type='Number'>$requestStatus</Value></Eq><Eq><FieldRef Name='IsInvitation'/><Value Type='Boolean'>0</Value></Eq></And></Where></Query></View> | ||
" | ||
$itemsToRemove | ForEach-Object { | ||
Remove-PnPListItem -List $accessRequestsList -Identity $_.Id -Batch $batch | ||
} | ||
Invoke-PnPBatch -Batch $batch | ||
Disconnect-PnPOnline | ||
``` | ||
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)] | ||
|
||
|
||
*** | ||
|
||
## Contributors | ||
|
||
| Author(s) | | ||
|-----------| | ||
| [Aimery Thomas](https://github.com/a1mery)| | ||
|
||
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)] | ||
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-remove-access-requests" aria-hidden="true" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[ | ||
{ | ||
"name": "spo-remove-access-requests", | ||
"source": "pnp", | ||
"title": "Remove site access requests", | ||
"shortDescription": "As a site owner, delete in bulk all the access requests from a SharePoint site.", | ||
"url": "https://pnp.github.io/script-samples/spo-remove-access-requests/README.html", | ||
"longDescription": [ | ||
"As a site owner, delete in bulk all the access requests from a SharePoint site using their status." | ||
], | ||
"creationDateTime": "2024-06-28", | ||
"updateDateTime": "2024-06-28", | ||
"products": [ | ||
"SharePoint" | ||
], | ||
"metadata": [ | ||
{ | ||
"key": "PNP-POWERSHELL", | ||
"value": "2.4.0" | ||
} | ||
], | ||
"categories": [ | ||
"Configure" | ||
], | ||
"tags": [ | ||
"Connect-PnPOnline", | ||
"New-PnPBatch", | ||
"Get-PnPList", | ||
"Get-PnPListItem", | ||
"Remove-PnPListItem", | ||
"Invoke-PnPBatch", | ||
"Disconnect-PnPOnline" | ||
], | ||
"thumbnails": [ | ||
{ | ||
"type": "image", | ||
"order": 100, | ||
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/spo-remove-access-requests/assets/preview.png", | ||
"alt": "" | ||
} | ||
], | ||
"authors": [ | ||
{ | ||
"gitHubAccount": "a1mery", | ||
"pictureUrl": "https://github.com/a1mery.png", | ||
"name": "Aimery Thomas" | ||
} | ||
], | ||
"references": [ | ||
{ | ||
"name": "Want to learn more about PnP PowerShell and the cmdlets", | ||
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.", | ||
"url": "https://aka.ms/pnp/powershell" | ||
} | ||
] | ||
} | ||
] |