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

GREYCstoration Oil Paint plugin for Photoshop

Service Bus Gateway service stuck at Starting

PowerApps SubmitForm not clearing People Picker value

Apple iPhone sending SMS automatically 00447786205094

SharePoint online hub navigation not updating for other users