2

I have been doing some testing in our labs for some new features we are working on. I purposely created some orphaned sites using a scenario I found in a blog and I ran into a strange side effect. What I did was use Remove-SPsite cmdlet to delete a certain site. I then ran the Restore-Spsite and wile this was in progress shut power to the machine. After successfully creating the orphaned site I ran the following:

foreach ($site in $sites)
{
       #$webs = $site | Get-SPWeb -Limit All
       $webs = $site.AllWebs
       foreach ($web in $webs)
}

in part of a script and when it came to the section where it went through the site collection with the orphaned site it stopped and threw up and exception error stating:

Failure Exception has been thrown by the target of an invocation.

I was able to correct the issue but was wondering if anyone else has seen this error as the result of an orphaned site when running cmdlets? Any information would be greatly appreciated. i know everyone is busy so thank you in advance for any feedback you have.

1 Answer 1

3

Wrap your code with

[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges( { 
   ...
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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