Broken Site Collection
[Tested on SharePoint 2016 only]
Suppose the following error occurs while creating a new site collection with a farm admin user account:
## Assume all declared variables are correct ##
PS C:\FarmAdminUserAccount> New-SPSite -Url $spSite -Name $scName -Description $scDesc -ContentDatabase $cdb -QuotaTemplate $scQuota -Template $scTemplate -Language 1033 -OwnerAlias $scPrimaryAdmin -OwnerEmail $scPrimaryEmail -SecondaryOwnerAlias $scSecondaryAdmin -SecondaryEmail $scSecondaryEmail
**********************
PS>CommandInvocation(Out-String): "Out-String"
>> ParameterBinding(Out-String): name="InputObject"; value="Calling extension methods on object Microsoft.SharePoint.Administration.SPContentDatabase+<>c__DisplayClass16 failed with exception(s):
The UPDATE permission was denied on the object 'MSP_TVF_WEB_ADMIN', database 'WSS_Content_DbName', schema 'pjpub'."
New-SPSite : Calling extension methods on object
Microsoft.SharePoint.Administration.SPContentDatabase+<>c__DisplayClass16 failed with exception(s):
The UPDATE permission was denied on the object 'MSP_TVF_WEB_ADMIN', database 'WSS2010_Content_DbName,
schema 'pjpub'.
At line:1 char:1
+ New-SPSite -Url $spSite -Name $scName -Description $scDesc -ContentDa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The error clearly indicates that the new site collection cannot be created due to a lack of the UPDATE permission on SQL. However, it does not provide any information regarding the current state of the new site collection you were attempting to create. This leads to the impression that it can be created with the appropriate permission. Consequently, you might either request your DBA to fix the permission on SQL or use the farm service account, which possesses all the necessary rights, to remote into the server and try to execute the same command again. When I chose the latter option, however, I encounter a different error:
>> TerminatingError(New-SPSite): "Cannot bind argument to parameter 'Url' because it is null."
**********************
Now you know something else is up. It's not just the permission issue. To examine the situation further, you find that:
- Running Get-SPSite does not return CompatibilityLevel or any other types of data about the site collection:
- Remove-SPSite fails to remove the corrupted site collection (using both the farm admin user and the farm service accounts) with the error, "<nativehr>0x80070003</nativehr><nativestack></nativestack>". The same issue occurs when you call the SPSite.Delete() method:
- Unfortunately, the Force parameter is not shipped with Remove-SPSite. Hence, the corrupted site collection cannot be force-deleted with that command:
Diagnosis
No atomic transaction occurs when the farm admin user lacks sufficient SQL permissions to create a new site collection. This issue can also arise in other situations, such as a network outage or a loss of session during execution.
Remedy
If you're unsure about your farm admin user's permissions on SQL, as a temporary workaround, use the farm service account to call the ForceDeleteSite() method of the SPContentDatabase object:
$corruptedSite = Get-SPSite "https://corruptedSiteCollectionUrl"
$corruptedSiteId = $corruptedSite.Id
$corruptedSiteId #To verify
$corruptedSiteDb = $corruptedSite.ContentDatabase
$corruptedSiteDb #To verify
($corruptedSiteDb).sites #To see all site collections in the content database
$corruptedSiteDb.ForceDeleteSite($corruptedSiteId, $false, $false)
Wait for a few minutes even after the execution has finished, and then run Get-SPContentDatabase nameOfContentDb to confirm.
For the ForceDeleteSite() method, refer to: https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/hh323680(v=office.14) Note that it shows, "Warning: This method should only be used when SPSite.Delete fails because the SPSite object was incompletely deleted or is otherwise corrupt."
For the permanent permission-related solution, grant the appropriate permissions to the farm admin user accounts as outlined in the Microsoft article. However, this may not cover all aspects or be as straightforward as it seems. More to come on this one....
Comments
Post a Comment