Fix: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

Scenario:
Trying to run a PowerShell script you get the following error:
The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

Fix:
Run this PowerShell script:

Add-SPShellAdmin -username domain\user

Note:
Sometimes the fix is required although the Get-SPShellAdmin command returns the user as having shell admin privileges. It could be the case that not all the farm servers are in sync.