PowerShell Script to Get Access request email SharePoint site in CSV File

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

function Get-ScriptDirectory
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
$localFolderObject = Get-ScriptDirectory
$localFolder = $localFolderObject.ToString() + “\”
#Get current working directory
$today = Get-Date
$filename = $localFolder + “RequestAccessEmail-On-Date—” + $today.Day.ToString() + “-” + $today.month.ToString() + “-” + $today.year.ToString() + “.csv”

#Please change the Site Collection URL
$site = “http://sharepoint.pasa.pas.local”

# Function: FindAccessEmail
# Description: Go through a target web application and list the title, url and access request email.
function FindAccessEmail

#Write the CSV Header – Tab Separated
“Site Title `t Site URL `t Request Email” | out-file $fileName
$WebApps = Get-SPWebApplication($site)
foreach($WebApplication in $WebApps)
foreach ($Collection in $WebApplication.Sites)
foreach($Web in $Collection.AllWebs)
$siteDetails = $Web.title+’——–‘+$Web.url+’————‘+$Web.RequestAccessEmail
$webName = $Web.title;

“$webName `t $weburl `t $webRequestAccessEmail” | Out-File $fileName -Append
write-host $siteDetails
Write-Output $siteDetails
Write-Output “Request Access Email report for the Given site collection has been generated, Please check this path: ” $fileName
#Run Script!

About Krishana Kumar

Krishana Kumar is SharePoint Architect/Trainer having Architecture experience with high volumes at Enterprise level and global scale - creation of highly scalable solutions with global user base and geographically distributed architectural components. Good knowledge of SharePoint best practices and governance models. I hold Two Master degree in Computer Science with over 11 years of experience working on Microsoft Technologies specially SharePoint, Project, .NET and other Information Worker Technologies. Having good exposer in Client side scripting Angular.js, backbone and Node. I am currently responsible for SharePoint Infrastructure set up and leading teams in various medium and large scale projects, architecting, designing & installing SharePoint farms, developing custom components,, and providing advanced SharePoint administration and development training to teams and customers. I regularly speaks in various SharePoint User Groups and other Events. I have MCSA Windows Azure, MCSA Office 365, MCSE & MCSD SharePoint 2013, Microsoft Certified Developer (MCD) and holds MCPD, MCTIP and MCTS for SharePoint 2010, MCTS MOSS 2007 & WSS 3.0, MCPD, MCITP (EPM 2010 & 2007) and MCSD .NET.
This entry was posted in General Interest. Bookmark the permalink.

Leave a Reply

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