PowerShell

Powershell – Access Request Settings (SharePoint 2010 & 2013)

I had a request to turn on all access requests or notifications on all sites with a web application. PowerShell is your best bet for doing these types of occasional tasks. This script will turn access requests on for all sites. Change the email address below to the intended recipient.

        # Get All Web Application
$webApp=Get-SPWebApplication
        # Get All site collections
    foreach ($SPsite in $webApp.Sites)
    {
        # get the collection of webs
       foreach($SPweb in $SPsite.AllWebs)
        {
        # if a site inherits permissions, then the Access request mail setting also will be inherited
             if (!$SPweb.HasUniquePerm)
               {
                  Write-Host $SPweb.Name "Inheriting from Parent site"
               }
             elseif($SPweb.RequestAccessEnabled)
           {
        #Write-Host $SPweb.Name "Not Iheriting from Parent Site"
          $SPweb.RequestAccessEmail ="jeremy@bondbyte.com"
          $SPweb.Update()
           }
        }
    }

About the author

Leave a Reply