Powershell Remote into Sharepoint Server help needed

Windows 7 Pro
Microsoft Windows Management Framework 4.0 (KB2819745) installed
Windows 2012 R2 Server
IIS 8.5
SharePoint 2010 SP2 Farm

Trying to run Powershell SharePoint CMDLETS on my Windows 7 Pro computer to connect to the Windows 2012 R2 server running SharePoint

I just installed Microsoft Windows Management Framework 4.0 (KB2819745) installed

so this is what I do
Enter-PSSession -ComputerName serv013 -Authentication CredSSP -Credential $crd

Enter a user and password and I am now connected  as you can see by the new prompt {SERV013}

Then  I add the Add-PSSnapin Microsoft.SharePoint.Powershell

[SERV013]: PS C:\> Add-PSSnapin Microsoft.SharePoint.Powershell

Then I issue this command and results below

[serv013]: PS C:\> $sites = Get-SPSite -Limit All | ?{$_.URL -Like "*/personal/*"}

Get-SPSite : Microsoft SharePoint is not supported with version 4.0.30319.34209 of the Microsoft .Net Runtime.
At line:1 char:10
+ $sites = Get-SPSite -Limit All | ?{$_.URL -Like "*/personal/*"}
+          ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:SPCmdletGetSite) [Get-SPSite], PlatformN
   otSupportedException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

I can issue server commands let Get-process   works great  just sharepoint commands not working

Thoughts

Thanks in advance
LVL 23
Thomas GrassiSystems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
Does the same thing happen when running PS on the SharePoint machine?  Hopefully you saw this from the WMF 4.0 download page.
Servers that are running the following applications can now run WMF 4.0. The versions listed are the minimum releases required to run WMF 4.0.
•Microsoft SharePoint Server 2010 with the February 2014 Cumulative Update

What's the latest cumulative update that you've installed?
Thomas GrassiSystems AdministratorAuthor Commented:
footech

Thanks for responding

On the windows 2012 server I open Powershell for SharePoint issue the same command and get a blank return meaning found nothing and no errors on the server console.

All my machines are updated by WSUS and current.

Do you mean SharePoint updates?  

is there a powershell cmdlet to tell you which version of sharepoint ?
footechCommented:
Yes, SharePoint updates.  I think you should be able to see installed updates via Central Administration > Upgrade and Migration > Check product and patch installation status.

Also, what version of PS is installed on the SharePoint server?

Edit:  Oh, and here's a link to the updates for SharePoint.  https://technet.microsoft.com/library/dn789211(v=office.14)
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

footechCommented:
What is the output of running $PSVersionTable when you can run the SP cmdlets on the server without error, and during your remote session?
Thomas GrassiSystems AdministratorAuthor Commented:
Footech

SharePoint 2010 is running Service Pack 2 KB2687453


On Server The SharePoint 2010 Management Shell is this
PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1


The Powershell version on the Windows 2012 Server is this

Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.

PS C:\U> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1


On my computer it is this
Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1


So the sharepoint management shell is outdated or am I using the wrong thing ?
footechCommented:
The full output of $PSVersionTable would be helpful (it provides some info on the .Net CLR).

I don't have an equivalent setup so I'll guess a bit.
If you look at the shortcut for the SP Management Shell, you'll see it starts PS with a version switch (-version 2.0), even on my machine which only has PS 2.0 installed (please verify if yours doesn't).  The version switch is used to run PS 2.0 even on machines that have a higher version installed.

You might have to configure PS to use the 2.x CLR.  I've seen some notes that it can be done, but haven't tried it myself.  Here's an example.  http://blogs.technet.com/b/alexsearch/archive/2013/12/11/sharepoint-2010-powershell-incompatibility-with-net-4-x.aspx
Thomas GrassiSystems AdministratorAuthor Commented:
Hello

Yes I was researching this myself and found you need to downgrade powershell for SharePoint 2010
Whats up with that?

Here is what I did

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.3.9600.16406
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2


PS C:\> PowerShell -v 2
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\> Enter-PSSession -ComputerName tgcs013 -Authentication CredSSP -Credential $crd
Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process
 the request. A computer policy does not allow the delegation of the user credentials to the target computer because th
e computer is not trusted. The identity of the target computer can be verified if you configure the WSMAN service to us
e a valid certificate using the following command: winrm set winrm/config/service '@{CertificateThumbprint="<thumbprint
>"}'  Or you can check the Event Viewer for an event that specifies that the following SPN could not be created: WSMAN/
<computerFQDN>. If you find this event, you can manually create the SPN using setspn.exe .  If the SPN exists, but Cred
SSP cannot use Kerberos to validate the identity of the target computer and you still want to allow the delegation of t
he user credentials to the target computer, use gpedit.msc and look at the following policy: Computer Configuration ->
Administrative Templates -> System -> Credentials Delegation -> Allow Fresh Credentials with NTLM-only Server Authentic
ation.  Verify that it is enabled and configured with an SPN appropriate for the target computer. For example, for a ta
rget computer name "myserver.domain.com", the SPN can be one of the following: WSMAN/myserver.domain.com or WSMAN/*.dom
ain.com. Try the request again after these changes. For more information, see the about_Remote_Troubleshooting Help top
ic.
At line:1 char:16
+ Enter-PSSession <<<<  -ComputerName SERV013 -Authentication CredSSP -Credential $crd
    + CategoryInfo          : InvalidArgument: (SERV013:String) [Enter-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

PS C:\>

This is all on my pc

I can connect with out credentials but then I get all kinds of errors from sql  on the sharepoint server

This connect works in powershell 2  "Enter-pssession -computername serv013"  but I need the CredSSP to work and it does not work on Powershelll 2 that is why I upgraded my windows 7 pro to Powershell 4

So the egg before the chicken or the chicken before the egg??????????
footechCommented:
What about using credentials without CredSSP?  I've used CredSSP with PS 2.0 before so I'm curious what problem you had - or is it just what you showed in your last post?
Thomas GrassiSystems AdministratorAuthor Commented:
Thanks

You have an example that works

Enter-pssession -computername serv013  ?????????????
footechCommented:
I happen to be doing some SharePoint migration testing right now, so I installed WMF 4.0 on a SP2010 box.  Here's something that looks like it's working:

On the SharePoint box, run
Register-PSSessionConfiguration -Name "SharePoint" -PowerShellVersion 2.0

Open in new window


On your machine
Enter-PSSession spserver -ConfigurationName "SharePoint"

Open in new window

Now you should be able to load the SharePoint snapin and run the cmdlets.
Thomas GrassiSystems AdministratorAuthor Commented:
footech

We are getting close

on the Server

Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1


PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.3.9600.17400
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2


PS C:\U> Register-PSSessionConfiguration -Name "SharePoint" -PowerShellVersion 2.0
WARNING: Register-PSSessionConfiguration restarts the WinRM service and all dependent services.
All WinRM sessions connected to Windows PowerShell session configurations, such as Microsoft.PowerShell and session
configurations that are created with the Register-PSSessionConfiguration cmdlet, are disconnected.

Confirm
Are you sure you want to perform this action?
Performing the operation "Register-PSSessionConfiguration" on target "Name: SharePoint SDDL:
O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows
PowerShell commands on this computer.".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y


   WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin

Type            Keys                                Name
----            ----                                ----
Container       {Name=SharePoint}                   SharePoint

Confirm
Are you sure you want to perform this action?
Performing the operation ""Restart-Service"" on target "Name: WinRM".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y


PS C:\>

Then got this error

Log Name:      System
Source:        Microsoft-Windows-WinRM
Date:          7/10/2015 7:07:28 PM
Event ID:      10149
Task Category: None
Level:         Warning
Keywords:      Classic
User:          N/A
Computer:      SERV013.FQDN.com
Description:
The WinRM service is not listening for WS-Management requests.

 User Action
 If you did not intentionally stop the service, use the following command to see the WinRM configuration:

 winrm enumerate winrm/config/listener
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-WinRM" Guid="{A7975C8F-AC13-49F1-87DA-5A984A4AB417}" EventSourceName="WinRM" />
    <EventID Qualifiers="7">10149</EventID>
    <Version>0</Version>
    <Level>3</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2015-07-10T23:07:28.000000000Z" />
    <EventRecordID>30475</EventRecordID>
    <Correlation />
    <Execution ProcessID="0" ThreadID="0" />
    <Channel>System</Channel>
    <Computer>TGCS013.our.network.tgcsnet.com</Computer>
    <Security />
  </System>
  <EventData Name="Stopped Listening">
  </EventData>
</Event>

then ran this

PS C:\> winrm enumerate winrm/config/listener
Listener
    Address = *
    Transport = HTTP
    Port = 5985
    Hostname
    Enabled = true
    URLPrefix = wsman
    CertificateThumbprint
    ListeningOn = 10.1.8.23, 10.2.8.23, 127.0.0.1, ::1, fe80::5efe:10.1.8.23%15

PS C:\>



On the Workstation

[tgcs013]: PS C:\>


Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\> Enter-PSSession SERV013 -ConfigurationName "SharePoint"
[tgcs013]: PS C:\> get-spsite
The term 'get-spsite' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (get-spsite:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

[SERV013]: PS C:\> Add-PSSnapin Microsoft.SharePoint.Powershell
[SERV013]: PS C:\> 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], SPCmdletE
   xception
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

[SERV013]: PS C:\>


[serv013]: PS C:\> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.8009
BuildVersion                   6.1.7601.18606
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1


[tgcs013]: PS C:\>

I was able to connect to the server  but unable to execute any commands it is a security issue no creditionals


Then on the server got these errors

Log Name:      Application
Source:        Microsoft-SharePoint Products-SharePoint Foundation
Date:          7/10/2015 7:10:59 PM
Event ID:      5586
Task Category: Database
Level:         Error
Keywords:      
User:          Mydom\me
Computer:      SERV013.FQDN.com
Description:
Unknown SQL Exception 5 occurred. Additional error information from SQL Server is included below.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server

is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-SharePoint Products-SharePoint Foundation" Guid="{6FB7E0CD-52E7-47DD-997A-241563931FC2}" />
    <EventID>5586</EventID>
    <Version>14</Version>
    <Level>2</Level>
    <Task>3</Task>
    <Opcode>0</Opcode>
    <Keywords>0x4000000000000000</Keywords>
    <TimeCreated SystemTime="2015-07-10T23:10:59.214194600Z" />
    <EventRecordID>31020</EventRecordID>
    <Correlation ActivityID="{8B3BE545-B9FF-0001-2444-4E8BFFB9D001}" />
    <Execution ProcessID="9980" ThreadID="11116" />
    <Channel>Application</Channel>
    <Computer>SERV013.fqdn.com</Computer>
    <Security UserID="S-1-5-21-3054588571-1341459584-784128302-1649" />
  </System>
  <EventData>
    <Data Name="int0">5</Data>
    <Data Name="string1">A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is

correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)</Data>
  </EventData>
</Event>


Thoughts
footechCommented:
Hmm, I had no trouble running running the Get-SPSite command.  I'm running SP2010 Foundation with SQL Express on the same box.  Maybe in your case it's a matter of credentials?  I would try adding them to the Enter-PsSession command.
Thomas GrassiSystems AdministratorAuthor Commented:
Footech

What are the parameters ?

I tried this

PS C:\> Enter-PSSession SERV013 -ConfigurationName "SharePoint" -Credential $crd
[SERV013]: PS C:\> Add-PSSnapin Microsoft.SharePoint.Powershell
[SERV013]: PS C:\> 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], SPCmdletE
   xception
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

[SERV013]: PS C:\>


Same event errors 5586

Thoughts
footechCommented:
You've already shown the correct parameter for including credentials above.
The only time I've gotten the "Cannot access the local farm..." error was when I started the SP Management Shell on the SP server without running as administrator, i.e. not in an elevated session.
See if you get the same error using CredSSP.

Going back through previous posts -
It looks like your SP version is SP2 without any further updates applied.  You may want to apply the latest cumulative update.
You mentioned before (before I suggested the PsConfiguration),"I can connect with out credentials but then I get all kinds of errors from sql  on the sharepoint server."  Are those the same errors that you're getting now?
Thomas GrassiSystems AdministratorAuthor Commented:
Footech

when I use CredSSP I get this

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\> Enter-PSSession -ComputerName serv013 -Authentication CredSSP -Credential $crd
[tgcs013]: PS C:\Users\spfarm\Documents> Add-PSSnapin Microsoft.SharePoint.Powershell
[tgcs013]: PS C:\Users\spfarm\Documents> get-spsite
Microsoft SharePoint is not supported with version 4.0.30319.34209 of the Microsoft .Net Runtime.
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:SPCmdletGetSite) [Get-SPSite], PlatformN
   otSupportedException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

[serv013]: PS C:\Users\spfarm\Documents>


When I use the suggested the PsConfiguration

PS C:\> Enter-PSSession SERV013 -ConfigurationName "SharePoint" -Credential $crd

I get the SQL Error 5586

I have used my account which is a domain admin account, I used the domain administrator account I even used the SharePoint Farm account all the same errors

My SQl Server is SQL 2008 Enterprise which is running on another Windows Server which is Windows 2008 R2  My SharePoint Database in its own SQL instance.


For the updates to sharepoint 2010 SP2 is the latest update I do not find any others

CA Upgrade Status is Succeeded
Managed Patch Status shows installed for many


Do I have a SQL permission problem? If that was true then how do my clients access sharepoint properly?

The SharePoint Powershell being 2.0 is the problem here.


Thoughts
footechCommented:
You should be able to use both CredSSP and the PsConfiguration at the same time.
Enter-PSSession SERV013 -ConfigurationName "SharePoint" -Credential $crd -Authentication CredSSP

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thomas GrassiSystems AdministratorAuthor Commented:
Footech


Success!!!!!!!!!!!!!

I can now issue SharePoint cmdlets using this comination

PS C:\> Enter-PSSession SERV013 -ConfigurationName "SharePoint" -Credential $crd -Authentication CredSSP
[SERV013]: PS C:\Users\administrator.MYDOM\Documents> Add-PSSnapin Microsoft.SharePoint.Powershell
[SERV013]: PS C:\Users\administrator.MYDOM\Documents> get-spsite

Url
---
http://sharepointabc.com
http://sharepointabc.com/my
http://sharepointabc.com/sites/Sharepoint2010
http://mysite.mydom.com
http://mysite.mydom.com/my/personal/mydom_thomas r g...


Now off to good things with Powershell


Thanks for all your help
footechCommented:
Super!  It must be that CredSSP is needed because SQL is on another server.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.