If you encounter problems when you are trying to execute a command or script which you know should work but does not consider checking that you are sufficient privileges to your environment where you are operating.
The most common problem I encounter regarding privileges is the error message when lets say you want to add a solution package.
The error message is something like this: “object reference not set to an instance of an object”. The message is misguiding you IF the problem is related to privileges.
Or another error message might go something like this: “Unable to access the local farm” or “The local farm is not accessible” etc.
If the case of insufficient privileges what is really going on is that you are missing some privileges to your environment or you do not have admin rights when executing scripts/commands.
Things to check:
- Check that the user account that you are using has sufficient privileges to do the operation that you want it to. Having rights to a site or site collection does not help you if you want to add a solution or delete one.
- Check that the user account has enough privileges in the SQL Server database. Depending on your operation that you are trying to perform either Content Database(s) or the Configuration Database.
- Check that you are running the Command Prompt or PowerShell as an Administrator. This applies to the following situation:
“If your user account is a member of the Administrators group, but is not the Administrator account itself, then, by default, the programs that you run only have standard user permissions. You must explicitly specify that you require the use of your administrative permissions by using one of the procedures in this topic.” Source: http://technet.microsoft.com/en-us/library/cc947813(v=ws.10).aspx
Hope this helps someone :).
PS. And always check you logs :). Both SP and Event logs of your server.