Tuesday, June 28, 2016

How to add a user to Web Application User Policy using PowerShell

To add a user to web application user policy using PowerShell , use the below PowerShell script

$userOrGroup = "i:0#.w|domain\user"
$displayName = "User-NTLM"

$webApp = Get-SPWebApplication("URL")
$policy = $webApp.Policies.Add($userOrGroup, $displayName)
$policyRole = $webApp.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl)
$policy.PolicyRoleBindings.Add($policyRole)
$webApp.Update() 

Thursday, June 23, 2016

You need to be a site collection administrator to set this property.

Issue Description

Recently I was trying to add a site collection administrator to a site and I got the belowmessage

You need to be a site collection administrator to set this property.   at Microsoft.SharePoint.ApplicationPages.ManageSiteAdminPage.BtnSubmit_Click(Object sender, EventArgs e)
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)




I was already the site collection administrator to the site and it did not make any sense.

Fix

On further trouble shooting, I found the solution for this.Browse to Central Administration - > Site Collection Quotas and Locks.

The options available here are:

       Not locked
Adding content prevented
Read-only (blocks additions, updates, and deletions)
No access

This site collection was in Read-only status. Unlock it (Change the status to  "Not Locked")