Connection error

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
Sharktracker
Posts: 11
Last visit: Tue Jul 14, 2020 8:53 am

Connection error

Post by Sharktracker »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: PowerShell Studio 2018 version 5.5.154

32 or 64 bit version of product: 64 bit
Operating system:
32 or 64 bit OS:64 bit

*** Please add details and screenshots as needed below. ***
I am running PowerShell Studio 2018 version 5.5.154
I can connect to the remote server without any issues
I can list the SharePoint cmdlet get-spsite and it shows up
When I try and run get-spsite (see below) I receive an error on any SharePoint command.
I am the admin of the SharePoint 2016 server and the SQL server

Any ideas why I receive the error?

[SERVERNAME]: PS C:\Users\Username\Documents> Add-PSSnapin Microsoft.SharePoint.Powershell

[SERVERNAME]: PS C:\Users\Username\Documents> get-command get-spsite

CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-SPSite 16.0.0.0 Microsoft.SharePoint.Powershell

[SERVERNAME]: PS C:\Users\Username\Documents> get-spsite
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], SPCmdletException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: Connection error

Post by brittneyr »

[TOPIC MOVED TO WINDOWS POWERSHELL FORUM BY MODERATOR]
Brittney
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Connection error

Post by jvierra »

You have to specify the site:

Get-SPSite 'http://<site name>'
Sharktracker
Posts: 11
Last visit: Tue Jul 14, 2020 8:53 am

Re: Connection error

Post by Sharktracker »

Get-spsite without any parameters returns a list of all the sites on the server.
Sharktracker
Posts: 11
Last visit: Tue Jul 14, 2020 8:53 am

Re: Connection error

Post by Sharktracker »

Why was this move from the PowerShell Studio forum to the Windows PowerShell forum.
I do not encounter this issue when using Windows powerShell. It occurs only whe I use Powershell studio 2018; therefore, it is a PowerShell Studio 2018 connectivity issue.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Connection error

Post by jvierra »

PowerShell Studio just runs the code in PowerShell. No code runs under PSS. Your question is about how to use a PS command and not how to use PSS.

Please post a simple example of your PSF file so we can look at what you are doing.
Sharktracker
Posts: 11
Last visit: Tue Jul 14, 2020 8:53 am

Re: Connection error

Post by Sharktracker »

No it is not.
I want to know why I get the error when using PSS to remotely connect to Powershell and running SharePoint Powershell cmdlets.

I do not have an issue with PS remotly connecting to Powershell and running SP PS cmdlets.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Connection error

Post by jvierra »

You cannot remotely execute many commands because of the "second hop" restriction. The error says that this is the cause as you are getting an error trying to connect to the farm. This is a limitation on all Windows remoting and is not caused by PSS.

"Cannot access the local farm"

This is because the farm is hosted on a remote server. The server you are remoting to cannot access the other servers from a remote connection.

Search for "second hop restriction" for more information.
Sharktracker
Posts: 11
Last visit: Tue Jul 14, 2020 8:53 am

Re: Connection error

Post by Sharktracker »

Actually just figured out how to connect and run SP PS cmdlets without importing remote cache which seems to be the problem.
This topic is 5 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked