There are two machines in this scenerio:
- client.sub.domain.com (client machine PSRemoting to remote server)
- server.sub.domain.com (remote server that client is PSremoting into)
I am using the below commands to start a psremote session using CredSSP to do "second-hop" authentication:
$session = New-PSSession -cn server.sub.domain.com -Credential $credential -Authentication Credssp
Invoke-Command -Session $session -ScriptBlock {. '\\client\Profile\Microsoft.PowerShell_profile.ps1'}
Invoke-Command -Session $session -ScriptBlock { Import-Module \\client\Profile\Modules\Posh-SSH }
Last line above produces the error below (this error happens with any binary module I use). I need this damn error to go away!
Could not load file or assembly 'file://\client\Profile\Modules\Posh-SSH\Assembly\Renci.SshNet.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) + CategoryInfo : validOperation: (:) [Import-Module], FileLoadException
Below are all things I've tried/verified:
On server.sub.domain.com:
PS C:\Users\MKANET\Desktop\Dev>Get-WSManCredSSP
The machine is not configured to allow delegating fresh credentials.
This computer IS CONFIGURED to receive credentials from a remote client computer.
On client.sub.domain.com:
PS C:\Users\MKANET\Desktop\Dev>Get-WSManCredSSP
The machine IS CONFIGURED to allow delegating fresh credentials to the following target(s): wsman/*.sub.domain.com
This computer is not configured to receive credentials from a remote client computer.
I put below in $PSHome\Powershell.exe.config on Client
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
On Client: (I tried running the below commands, since nothing else worked. Needless to say, this didn’t help any.)
Set-Alias CasPol "$([Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory())CasPol.exe"
CasPol -pp off -machine -addgroup 1.2 -url file://\S858018\Profile\Modules\* FullTrust
On both client and server:
PS C:\Users\MKANET\Desktop\Dev>$psversiontable
Name Value
---- -----
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.1008
PSRemotingProtocolVersion 2.2