SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've adapted a PowerShell script from Harry Chen's "SharePoint Connoisseur" blog to solve the broken Navigation Up issue he describes. My code is slightly modified, but only to reduce the data captured and the sample size. Here's a code snippet:

$data = @()

  $site = Get-SPSite -Identity "http://theclients/site/collection"
Catch [system.exception]
  Write-Host $_.Exception.ToString()

foreach($web in $site.AllWebs)
  foreach($list in $web.Lists)
    if($list.Title -eq "Pages")
       DO STUFF

When I attempt to run the script (from SharePoint 2010 Management Shell as Administrator) I receive the following error:

C:\GetPagesInNeedOfUpdate.ps1 : Exception has been thrown by the target of an i
At line:1 char:30
+ C:\GetPagesInNeedOfUpdate.ps1 <<<<
    + CategoryInfo          : NotSpecified: (:) [GetPagesInNeedOfUpdate.ps1],
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,GetP

Which is pretty ambiguous. Also, there is no character 30 at line 1...

Is this a permissions issue? The execution policy is set to Unrestricted so I know it isn't that, and my user has full control and is the primary site collection administrator.

What could be causing this?

share|improve this question
up vote 0 down vote accepted

I never got this script to work. I just checked the pages manually and manually removed the controls causing this... lame... if someone else has an answer I'd gladly accept it.

share|improve this answer

Add the user account running the script to the Site Collections that you have and the error would go away.

As it turns out, it was permissions all along.

Hope it helps.

share|improve this answer

your code is outside the try code block

share|improve this answer
Perhaps you could expand on why you think this is a problem. Thanks. – SPDoctor Sep 21 '12 at 12:15
The first line runs successfully outside of the script. It's just initialization. – RJ Cuthbertson Sep 21 '12 at 13:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.