Powershell 3.0 从远程共享导入二进制模块 [英] Powershell 3.0 Importing binary module from remote share

查看:40
本文介绍了Powershell 3.0 从远程共享导入二进制模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个场景中有两台机器:

There are two machines in this scenerio:

  • client.sub.domain.com(客户端机器 PSRemoting 到远程服务器)
  • server.sub.domain.com(客户端正在远程连接的远程服务器)

我使用以下命令启动 psremote 会话,使用 CredSSP 进行second-hop" 身份验证:

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!

无法加载文件或程序集file://\client\Profile\Modules\Posh-SSH\Assembly\Renci.SshNet.dll"或其依赖项之一.不支持操作.(来自 HRESULT 的异常:0x80131515)+ CategoryInfo : validOperation: (:) [Import-Module], FileLoadException

以下是我尝试/验证的所有内容:

Below are all things I've tried/verified:

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.

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.

我在客户端的$PSHome\Powershell.exe.config 中放入下面

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

在客户端和服务器上:

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

推荐答案

远程机器上接收invoke-command的进程不是powershell.exe,而是wsmprovhost.exe.如果您希望它产生任何效果,您需要像更改 powershell.exe 一样更改该进程的配置文件.

The process that is receiving the invoke-command on the remote machine is not powershell.exe, but wsmprovhost.exe. You would need to change the config file of that process like you did for powershell.exe if you want it to have any effect.

Fusion log 可用于调试程序集加载问题.请务必在您的远程计算机上执行此操作,因为在那里进行程序集加载.

Fusion log can be of use when debugging assembly loading problems. Be sure to do this on your remote machine since that is where the assembly loading takes place.

你也在远程机器上试过 caspol 的东西吗?

Also have you tried the caspol thing on the remote machine?

这篇关于Powershell 3.0 从远程共享导入二进制模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆