0

I know Central Admin can be controlled using PowerShell mostly if not all. What I'm trying to figure out is if there's a way to enable/disable the creation of subsites in Central Admin using a PowerShell script.

enter image description here

1
$webApp = Get-SPWebApplication -Identity http://mywebapp
$allowSubsites = $false


$newPermissions=$null   
if ($allowSubsites){
    $newPermissions=[Microsoft.SharePoint.SPBasePermissions]($webApp.RightsMask -bor [Microsoft.SharePoint.SPBasePermissions]::ManageSubWebs)
}
else
{
    $newPermissions=[Microsoft.SharePoint.SPBasePermissions]($webApp.RightsMask -band [System.Int64](-bnot ([Microsoft.SharePoint.SPBasePermissions]::EmptyMask -bor [Microsoft.SharePoint.SPBasePermissions]::ManageSubWebs)))
}

$webApp.RightsMask = $newPermissions
$webApp.Update()

Reference: https://stackoverflow.com/questions/18986946/programmatically-access-user-permissions-for-web-application-in-sharepoint-2010

  • Does this work with SharePoint 2013? Im getting this error message: Cannot convert value "18446744073701163007" to type "System.Int64". Error: "Value was either too large or too small for an Int64." – Vader May 31 '18 at 22:04
0

Use below:

$webApp = Get-SPWebApplication "WEBAPPURL"
$newPermissions=[Microsoft.SharePoint.SPBasePermissions]($webApp.RightsMask - 
band [System.Int64](-bnot ([Microsoft.SharePoint.SPBasePermissions]::EmptyMask -bor [Microsoft.SharePoint.SPBasePermissions]::ManageSubWebs)))
$webApp.RightsMask = $newPermissions
$webApp.Update()

Executing these lines will automatically remove the “Create Subsite” permission from your web application, thus prevent any users from ever creating subsite.

Refer below for more details: http://nikcharlebois.com/prevent-subsite-creation-in-sharepoint-using-powershell/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.