Report for SharePoint Access Request Email Configurations

Requirement:
People are moving to different roles, Few left the company from time to time. Access requests are sent to those of that kind. It’s a problem! We had to monitor the access request configurations to make sure its sent to the relevant person. So, wrote this PowerShell code to generate the report for SharePoint access request email address configurations.

PowerShell to Generate Report on Access Requests Configuration:

Use this PowerShell script to get a list of all access request configurations:

#Set-ExecutionPolicy RemoteSigned
$OutputFN = "AccessRequestConfigs.csv"
#delete the file, If already exist!
if (Test-Path $OutputFN)
{ 
	Remove-Item $OutputFN 
}
#Write the CSV Headers
"Site Collection Name, Site Name ,URL ,Access Requst E-Mail" > $OutputFN

# Get All Web Applications 
$WebAppServices=Get-SPWebApplication

foreach($webApp in $WebAppServices)
{
	# Get All Site collections
	foreach ($SPsite in $webApp.Sites)
	{
	   # get All Sites 
	   foreach($SPweb in $SPsite.AllWebs)
		{
		  if($SPweb.RequestAccessEnabled -eq $True)
		  {
		   $SPsite.Rootweb.title + "," + $SPweb.title.replace(","," ") + "," + $SPweb.URL + "," + $SPweb.RequestAccessEmail >>$OutputFN
		 
		  }
		  $SPweb.dispose()
		}
	  $SPsite.dispose()
	}
}

and the Output:

sharepoint 2010 access request email address

Here is the MOSS 2007 Version to get access request Emails:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

#For SharePoint 2007 compatibility
function global:Get-SPSite($url){
    return new-Object Microsoft.SharePoint.SPSite($url)
}
 
#Get the web application
Write-Host "Enter the Web Application URL:"
$WebAppURL= Read-Host
$SiteColletion = Get-SPSite($WebAppURL)
$WebApp = $SiteColletion.WebApplication

$OutputFN = "AccessRequestConfigs.csv"
#delete the file, If already exist!
if (Test-Path $OutputFN)
 {
    Remove-Item $OutputFN
 }

#Write the CSV Headers
"Site Collection Name, Site Name ,URL ,Access Requst E-Mail" > $OutputFN
 
# Get All Site collections
foreach ($SPsite in $webApp.Sites)
{
	# get All Sites
	foreach($SPweb in $SPsite.AllWebs)
	{
		if($SPweb.RequestAccessEnabled -eq $True)
		{
		$SPsite.Rootweb.title + "`t" + $SPweb.title + "`t" + $SPweb.URL + "`t" + $SPweb.RequestAccessEmail >>$OutputFN

		}
		$SPweb.dispose()
	}
	$SPsite.dispose()
}

Related Posts:

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

5 thoughts on “Report for SharePoint Access Request Email Configurations

  • I tried to run it and get the following error:

    E:PSscriptsShowInfoAccessRequestReport.ps1 : Exception has been thrown by the target of an invocation.

    Reply
    • Eric,

      It could be a permissions issue! Make sure you have permissions to that sites you are querying.

      Use Try Catch to Debug the issue by printing the Exception, which should tell you the cause of the real problem! Make sure you are running the script with valid SharePoint URL and from a WFE.

      Reply
  • Perfect! I had a support rep request this very thing, after finding this article I was able to send the info to him in less than 5 minutes. Much Thanks!

    Reply
  • Can you send me the same for SharePoint 2007 ?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *