Please find below is the PowerShell script to check if the access request settings are enabled on SharePoint Site and update the email address.
Here It will iterate through all the site collection for particular web application given by you.
- 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 to whom Access request will be sent : "
-
- 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."
- }
- }
- }