Monday, August 5, 2013

PowerShell SPWeb.Webs exception has been thrown by the target of an invocation

When I am working with PowerShell to do some operations on sub sites I found the below issue :

Code for this issue :

foreach($web in $MainWeb.Webs)
{

}


In the above code $MainWeb.Webs is throwing error.

Issue :
Exception has been thrown by the target of an invocation

Cause :
I have done so much work around for this issue. Finally figured out that issue is because of the Permissions.

Resolution :
Script executor / Remote server login user must be site collection administrator to get rid of this error.

Thank you !!!

No comments:

Post a Comment