Disable "Request Access" in SharePoint using PowerShell

Hi There,

Using below code, you can disable or hide or remove "Request Access" option from SharePoint. It worked for SharePoint 2010 (could be working for SharePoint 2013).

$contentWebAppServices = (Get-SPFarm).services |
? {$_.typename -eq "Microsoft SharePoint Foundation Web Application"}
# Get All Web Application
foreach($webApp in $contentWebAppServices.WebApplications)
{
Write-Host $webApp.name 
    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 "Inheriting from Parent site"
               }
             elseif($SPweb.RequestAccessEnabled)
           {
              $SPweb.RequestAccessEmail =""
              $SPweb.Update()
           }
        }
    }
}


Hope it will save one's day.
Regards

Comments

Popular Posts

Apple iPhone sending SMS automatically 00447786205094

GREYCstoration Oil Paint plugin for Photoshop

Security Token Service is not available (I fixed it)

SharePoint online hub navigation not updating for other users

Service Bus Gateway service stuck at Starting