【发布时间】:2020-02-07 18:26:54
【问题描述】:
使用 docker 运行 powershell 核心(微软官方图像), 我正在尝试在我的脚本中设置一个本地会话,以便稍后在该会话中执行代码。
我曾尝试使用以下 Linux 映像:
6.2.3-alpine-3.8
6.2.3-centos-7
6.2.3-debian-9
6.2.3-ubuntu-18.04
在 alpine 和 debian 中出现错误:
This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.
在 Centos 和 Ubuntu 中都出现错误:
MI_RESULT_ACCESS_DENIED
我尝试挖掘错误但仅在尝试从 linux 远程到 windows 的情况下被提及,而在这里我要做的只是打开最基本的本地会话。
$FullCommand = "Invoke-Expression $CompleteScript"
$Session = New-PSSession
[scriptblock]$ScriptBlock = [scriptblock]::Create($FullCommand)
Invoke-Command -Session $Session -ScriptBlock $ScriptBlock
或
$Session = New-PSSession
Invoke-Expression -Session $Session -Command $CompleteScript
在开始从 linux 到 windows 的远程会话之前,我想建立一个本地会话并能够在其上执行代码。
我是 powershell 新手,所以可能会遗漏一些东西,但我希望本地会话至少可以处理 microsoft 的 powershell 核心的官方 docker 映像之一,那里的文档没有让我对这个问题有任何见解。
【问题讨论】:
标签: powershell docker ubuntu powershell-remoting powershell-core