Saturday, June 23, 2012

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 in that kind. Its 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 code to Generate Report on Access Requests Configuration:

#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:



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

5 comments :

  1. Can you send me the same for SharePoint 2007 ?

    ReplyDelete
    Replies
    1. Updated with the code for SharePoint 2007!

      Delete
  2. 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!

    ReplyDelete
  3. I tried to run it and get the following error:

    E:\PSscripts\ShowInfo\AccessRequestReport.ps1 : Exception has been thrown by the target of an invocation.

    ReplyDelete
    Replies
    1. 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.

      Delete

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...