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.


Access Requests

If you have configured outgoing email settings and allowed your users to send you access requests in the site collection settings like in the image below when they navigate to the site where they have no permissions they will receive a message "Let us know why you need access to this site."






After they send the request, the message appears under Site Settings>Access requests and invitations. There you can either approve or reject the request and set appropriate permission level. If you are interested in approving or rejecting the requests using Powershell, please refer to Approve or decline Access Requests in SharePoint 2013/2016 using Powershell and CSOM.

SPOMod

In order to execute cmdlets in the lines below, you need to install SharePoint SDK and download SharePoint Module for managing lists, items and files, which includes custom cmdlets used in this article. You can click here to start the download directly.


Get Access Requests from Multiple Sites

1. Define $sites. You can use all existing site collections:
$sites=(get-spsite).Url

Or just a subset of them:

2. Retrieve access requests for each site:
foreach($site in $sites){ Connect-SPCSOM -Credential $cred -Url $site; Get-SPOListItems -ListTitle "Access Requests" -IncludeAllProperties $true }


Export Access Requests to a report

If you want to export the access requests to a .csv file, run the following cmdlet. The "-Append" parameter ensures that the results from different sites will be added to the same file and not overwrite each other.
foreach($site in $sites){ Connect-SPCSOM -Credential $cred -Url $site; Get-SPOListItems -ListTitle "Access Requests" -IncludeAllProperties $true| export-csv c:\accessrequests.csv -Append }


See Also

SharePoint 2013/2016: Missing Access Request Settings
SharePoint 2013/2016: Approve or decline Access Requests using Powershell and CSOM


web
statistics