Wednesday, 30 September 2015

New-SPWeb : Access is denied

Ran into an interesting one recently. While trying to create a new site in my 2013 site collection, I got the following error message:

PS C:\Windows\system32> New-SPWeb http://intranet/communities/eim/MD -Template "CMSPUBLISHING#0" -Name "Master Data"
New-SPWeb : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At line:1 char:1
+ New-SPWeb http://intranet/communities/eim/MD -Template "CMSPUBLISHING#0" -Nam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share....SPCmdletNewWeb:SPCmdletNewWeb) [New-SPWeb], UnauthorizedAccessException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewWeb

Turned to Google and found that I needed to add the user account executing the code, in my case the farm setup account, to the site collection admin group. Strange, because I used the same script previously on a 2010 site collection without the user being in the site collection admin group.

Ping back: http://dirty-dot.blogspot.co.za/2012/04/i-ran-into-another-odd-problem-with-my.html