Error: “Cannot access the local farm” – PowerShell command error
When working with PowerShell I got an error. First I thought I am making some kind of a mistake because I am new to this as well 
So I was struggling to make it happen and finally figured it out. The solution was to have administrator privileges to run PowerShell. So when you want use PowerShell don’t just click on it. Right click and Run as Administrator
Bingo! Now you can use it.

Please add a comment if you use this code or it helped you. So I can make my posts better.