Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 = @()

Try
{
  $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
nvocation.
At line:1 char:30
+ C:\GetPagesInNeedOfUpdate.ps1 <<<<
    + CategoryInfo          : NotSpecified: (:) [GetPagesInNeedOfUpdate.ps1],
  TargetInvocationException
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,GetP
  agesInNeedOfUpdate.ps1

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
add comment

3 Answers

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 comment

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
add comment

your code is outside the try code block

share|improve this answer
1  
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
add comment

Your Answer

 
discard

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.