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”
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!