Set Access Request Email on All Sub-Site of a Web Application

Hi all!

Follow a Powershell script to change the Access Request email for all sites in a we b application:

$webapp = Get-SPWebApplication "http://yourwebapplication.com"
$currentEmail = "current.email@company.com";
$newEmail = "new.email@company.com";

foreach($site in $webapp.Sites)
{
   foreach($web in $site.AllWebs)
   {
     $url = $web.url
	 Write-host $url
     if (!$web.HasUniquePerm)
     {
            Write-Host "Access Request Settings is inherted from parent."
     }
       elseif($web.RequestAccessEnabled)
       {
			Write-Host "Access Request Settings is enabled."
			write-host $web.RequestAccessEmail
	        if ($web.RequestAccessEmail -eq $currentEmail)
			{
				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."
      }
   }
}

 

Hope this helps you!

 

See you,
Amadeu.

Advertisements