CSC510243. Do not change SPPersistedObject in the content web application.
SharePoint 2010+ has security feature to all objects inheriting from SPPersistedObject. This feature explicitly disallows modification of SPPersistedObject objects from content web applications (not CA).
- Rescope your features so that web application related activity are performed by a web application scoped feature. Notice that you cannot use a site scoped feature - this would just throw another Access Denied error.
- Disable the security setting (we won't suggest this, the security setting was created with a purpose in mind), either via power shell or a console app.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") > $null
# get content web service
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
# turn off remote administration security
$contentService.RemoteAdministratorAccessDenied = $false
"The SPPersistedObject, XXXXXXXXXXX, could not be updated because the current user is not a Farm Administrator" craziness in Sharepoint 2010