Forum Discussion

Nissan Dookeran's avatar
Nissan Dookeran
Copper Contributor
Jan 06, 2018
Solved

Cannot execute SharePoint Powershell commands from remote powershell

I am trying to use Powershell remoting to run SharePoint Powershell commands from my client machine after remoting to the SP Server. I am getting the following error

Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you
have the appropriate permissions to access the database before trying again.
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:SPCmdletGetSite) [Get-SPSite], SPCmdletE
   xception
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

 

 

The attached screenshot shows the complete order of execution of commands. Can anyone assist here?

  • Try running PowerShell "As Administrator", then (substituting farm credentials)

     

    runas.exe /noprofile /env /user:domain\farmadmin "powershell.exe"

     

    This should start new PowerShell window running as the Farm Administrator. Then:

     

    asnp microsoft.sharepoint.powershell

     

    You can use

     

    Add-SPShellAdmin domain\username

     

    to give yourself Shell Admin access.

     

     

  • Try running PowerShell "As Administrator", then (substituting farm credentials)

     

    runas.exe /noprofile /env /user:domain\farmadmin "powershell.exe"

     

    This should start new PowerShell window running as the Farm Administrator. Then:

     

    asnp microsoft.sharepoint.powershell

     

    You can use

     

    Add-SPShellAdmin domain\username

     

    to give yourself Shell Admin access.

     

     

Resources