0

I'm trying to manage a number of publishing sites through PowerShell. It's fine on nearly all of them, but one of my publishing sites seems to have a problem.

Consider the following PowerShell script:

$NewWeb = Get-SPWeb $DestWeb 
$NewSite = Get-SPSite $DestSite

foreach($list in $NewWeb.Lists)
{
Write-Host "Library: $($list.Title); ListID: $($list.ID)" -ForegroundColor Green
}

$NewPublishingSite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($NewSite) 
$NewPublishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($NewWeb) 

$DefaultPage = $NewPublishingWeb.DefaultPage
Write-host "DefaultPage = $DefaultPage"
$PagesList = $NewPublishingWeb.PagesList.ID
Write-Host "PagesList ID = $($PagesList)"
$NewPublishingPages = $NewPublishingWeb.GetPublishingPages()
foreach ($NewPage in $NewPublishingPages)
{
Write-Host $NewPage.ListItem["Title"] -ForegroundColor Yellow
}

When I run this on almost all of my publishing sites, I get a nice list of the titles and ID's of all of the libraries, as well as a list of all of the publishing pages in the site.

However, in my rogue site, I don't. This first element works fine - getting a list of all of the libraries and their List ID's.

It's the second bit that doesn't - interacting with the Publishing site itself. The above script gives the following result:

Library: Composed Looks; ListID: 4ed58df1-d48c-4865-8505-11e52ad599d3 Library: Documents; ListID: f06f4a2c-d715-4f56-8bc2-2c68e45e416b Library: Images; ListID: 012fe035-73e0-463d-8967-83206bfe6236 Library: Master Page Gallery; ListID: 6b53ed8f-01dd-44c9-a4be-6defeafd3e79 Library: Media Library; ListID: 68a0bdf7-3bce-4071-a017-b87f6adc2969 Library: Pages; ListID: 01acbbda-373a-4faf-8fd0-0919103c9de8 Library: Site Assets; ListID: 08d350d3-188e-40ff-b53e-bbd4e22b57f0 Library: Site Collection Images; ListID: 6c7942de-1c92-496c-987a-9fdbabe3ef99 Library: Workflow Tasks; ListID: 67c29840-d699-42be-894b-4053cb7765f7 DefaultPage = Pages/news.aspx PagesList ID =

Exception calling "GetPublishingPages" with "0" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" At line:17 char:1 + $NewPublishingPages = $NewPublishingWeb.GetPublishingPages() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : UnauthorizedAccessException

As you can see, the script clearly has access to the site (as it is able to perform the first half of the function).

However, it doesn't seem to pick up the PublishingPagesList, nor is it able to do anything else "publishingWeb" related. It says that it doesn't have access, even though it does (see earlier results).

What's the issue?

  • Update - it's only on this web app; the other web apps are fine – user1259798 Feb 8 at 22:52

Your Answer

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

Browse other questions tagged or ask your own question.