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 is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

5 thoughts on “Report for SharePoint Access Request Email Configurations

  • May 22, 2013 at 3:41 PM

    I tried to run it and get the following error:

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

    Reply
    • May 23, 2013 at 8:41 AM

      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
  • November 7, 2012 at 5:26 PM

    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
  • October 16, 2012 at 7:25 PM

    Can you send me the same for SharePoint 2007 ?

    Reply

Leave a Reply