Wednesday, March 8, 2017

Powershell & SharePoint Exception has been thrown by the target of an invocation

The other day I was logged into my SharePoint server with my local admin user account and tried to run a powershell script against my farm and got an error that had me scratching my head. The error was "Exception has been thrown by the target of an invocation"

The error really made no sense since I had admin rights to the farm, but upon further investigation I found that my account didn't have the rights it needed to access some sites.

Solution was to go to central admin and select
 Application Management > Manage Web Applications >Select the web app you need access to >From the Ribbon select User Policy>Add Users

Here I added my account with Full Control and clicked save and then ran my powershell script again and it successfully executed.