15 49.0138 8.38624 1 0 4000 1 https://vladtalkstech.com 300 1
theme-sticky-logo-alt

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

7 Comments

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

Previous Post
A review of the SharePoint Outlook integration tool by harmon.ie
Next Post
An unexpected error has occurred when a user clicks on My Settings to access MySites

7 Comments

  • March 12, 2014 at 4:53 am
    anil alladi

    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.

    Reply
    • March 14, 2014 at 12:27 am

      Did you run powershell as an administrator?

      Reply
      • March 14, 2014 at 1:44 am
        anil alladi

        yes

    • October 12, 2016 at 11:55 am
      Dan

      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.

      Reply
  • September 9, 2014 at 9:42 am
    moreno

    installed powershell 3.0 and it should resolve it

    Reply
  • February 26, 2015 at 3:12 pm
    Bart Kuppens

    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.

    Reply
  • October 7, 2015 at 12:02 am
    karzon

    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

    Reply

Leave a Reply