Wednesday, March 6, 2013

Fix Sharepoint/Powershell Error: The Farm is Unavailable

Below is an error that you can get in PowerShell or via STSADM for SharePoint

PS C:\> Get-SPServiceApplicationProxy
Get-SPServiceApplicationProxy : The farm is unavailable.
At line:1 char:30
+ Get-SPServiceApplicationProxy <<<<
    + CategoryInfo          : ResourceUnavailable: (Microsoft.Share...pplicationProxy:SPCmdletGetServiceApplicationProxy) [Get-SPServiceApplicationProxy], InvalidOperationException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetServiceApplicationProxy

This error occurs when the user running the command doesn't have enough access to the SQL server. You can either grant this user account more rights in SQL, or login and run the command with the farm admin account and this error should go away.

If you already have the SecurityAdmin role in SQL, you can run "Add-SPShellAdmin -UserName DOMAIN\User" at a powershell prompt to grant the rights rights in SQL that are needed as well.