Objective
This purpose of this document is to mention the steps to access request settings page email address using PowerShell Script. Whenever we try to access an unauthorized site, we are redirected to Access denied page, in that case we can request an access and our request will be sent to a person whose email address is configured in access request settings as email.
Note:
By default, Primary Site Collection Administrators' email addresses are configured in access request settings page whenever a new site collection gets created.
Business Case
S. No. | Business Case |
1 | For several reasons customer want to maintain an access matrix to avoid any kind of access violations. So every access request to a SharePoint site must be routed through a group of users who will validate and provide a necessary access to user. For this, we need to configure an email address of compliance team in access request settings, so that access request is routed. |
Targeted Audience
- SharePoint Application Developers
- SharePoint Administrator
- SharePoint Architect
Technical Details
Below are the technical details for this PowerShell script,
- Execution
Run:
- Run the PowerShell Script as “Run as Administrator“.
- Browse the folder path where you have kept this PowerShell script file and execute a command.
PowerShell Script
- ##########################################################################################################################
- ######## V 1.0
- ######## PowerShell Script to update access request settings page email address
- ##########################################################################################################################
-
- if ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null )
- {
- Add-PsSnapin "Microsoft.SharePoint.PowerShell"
- }
-
- $WebapplicationValue = Read-Host "Enter web application URL"
- Write-Host $WebapplicationValue
-
- $webapp = Get-SPWebApplication $WebapplicationValue
- $newEmail = Read-Host "Enter Email Address:"
- Write-Host $newEmail
-
- foreach($site in $webapp.Sites)
- {
- Write-Host "Site URL is" $site
- foreach($web in $site.AllWebs)
- {
- $url = $web.url
- Write-host "Site URl"$url
- if (!$web.HasUniquePerm)
- {
- Write-Host "Access Request Settings is inherted from parent."
- }
- else
- {
- if($web.RequestAccessEnabled)
- {
- Write-Host "Access Request Settings is enabled."
- Write-Host "Email needs to be updated."
- $web.RequestAccessEmail = $newEmail
- $web.Update()
- Write-Host "Email changed successfully!"
- }
- }
- else
- {
- Write-Host "Access Request Settings not enabled."
- }
- }
- }