SharePoint Management Shell – Exception has been thrown by the target of an invocation

SharePoint Management Shell – Exception has been thrown by the target of an invocation

While running PowerShell scripts on a SharePoint Server you might encounter this error “Exception has been thrown by the target of an invocation”

Exception has been thrown by the target of an invocation

The error is really not self-explanatory, however the only problem is that you don’t have enough permissions on the Site or Web in question. Even if you are a farm admin and local admin on the server, some SharePoint PowerShell Commands will not allow you to run at the SITE or Web level.

Easiest way to fix it, since you already have access to the server, give yourself Full Control at the Web Application Level (in User Policy) and you shouldn’t have this problem anymore!

Leave  a comment and don’t forget to like us on Facebook here and to follow me on Google+ here and on Twitter here  for the latest news and technical articles on SharePoint.  Also, don’t forget to check out SharePoint Community.Net for more great SharePoint Content

No ratings yet.

Please rate this

 
Comments

I already have full control on a particular web application, and I am one of the farm administrators too.
But still I am getting the above error while executing one powershell script.

Did you run powershell as an administrator?

Add your user account to the local group (in Computer Management), WSS_RESTRICTED_WPG_V4. This group should give you the necessary rights to run SharePoint Management Shell.

Alternatively, if you have the password for the Farm Administrator (the user running owstimer.exe), simply run PowerShell “As Administrator”, then use runas.exe /noprofile /env /user:domain\farmadmin “powershell.exe”. This will launch a new instance of PowerShell running as the Farm Administrator. Then simply import the SharePoint snapin using:

Add-PSSnapin Microsoft.SharePoint.PowerShell

You can then use Add-SPShellAdmin domain\yourusername to add yourself to the Shell Admins, thus granting yourself access.

This came from https://social.msdn.microsoft.com/Forums/en-US/4bb315e8-1684-49c1-b9b2-a80cdd56490d/cannot-access-local-farm-how-to-use-addspshelladmin?forum=sharepointgeneralprevious

it worked for me.

installed powershell 3.0 and it should resolve it

I had the same thing…. farm admin, full control policy. I was even site collection admin. No access. Then I ran add-spshelladmin on the content database and that did the trick.

I have added the user in Full Control at the Web Application Level (in User Policy) and working fine.
web application->User Policy->Add User as Full Control

Leave a Reply