The article below is using SharePoint Module for managing lists, items and files as an extension to SharePoint Management Shell. Install the module to proceed.

Find Access Requests

Import-Module C:\Users\Administrator\Desktop\SPOModCURRENT20170306.psm1
Connect-SPCSOM -Username Administrator -Url http://nicename:17007/sites/devSite
Get-SPOListItems -ListTitle "Access Requests" -IncludeAllProperties $true

Approve Access Requests

In order to approve or decline the access requests you need to update the field "Status". Value 1 means "Approved". See below for all possible values.

Set-SPOListItem -ListTitle "Access Requests" -ItemID 1 -FieldToUpdate Status -ValueToUpdate 1

Decline Access Requests

In order to decline the access requests you need to update the field "Status". Value 3 means "Declined". See below for all possible values.

End effect:

Possible Values for Status Field

0   pending  
1   approved
2   accepted 
3   declined 

Bulk-approve all access requests

To see access requests

Get-SPOListItems -ListTitle "Access Requests" -IncludeAllProperties $true | select requestedBy

In order to approve all access requests in a given site, execute the following cmdlets:

$items=(Get-SPOListItems -ListTitle "Access Requests" -IncludeAllProperties $true)
foreach($item in $items) {Set-SPOListItem -ListTitle "Access Requests" -ItemID $item.ID -FieldToUpdate Status -ValueToUpdate 1}

End effect:

Bulk-decline all access requests

In order to decline all access requests in a given site, execute the following cmdlets:

$items=(Get-SPOListItems -ListTitle "Access Requests" -IncludeAllProperties $true)
foreach($item in $items) {Set-SPOListItem -ListTitle "Access Requests" -ItemID $item.ID -FieldToUpdate Status -ValueToUpdate 3}

Bulk-approve only pending access requests

In order to approve all pending access requests in a given site, execute the following cmdlets:

$items=(Get-SPOListItems -ListTitle "Access Requests" -IncludeAllProperties $true | where {$_.Status -eq 0})
$items | select Status
foreach($item in $items) {Set-SPOListItem -ListTitle "Access Requests" -ItemID $item.ID -FieldToUpdate Status -ValueToUpdate 1}

Verify the end results:

Get-SPOListItems -ListTitle "Access Requests" -IncludeAllProperties $true | select status

Other Languages

The article is available in other languages:

Zatwierdzanie lub odrzucanie żądań dostępu w programie SharePoint 2013/2016 za pomocą programu Powershell i CSOM (pl-PL)


website statistics