如何在Docker中安装PowerShell社区扩展?

pcww981p  于 2023-06-05  发布在  Docker
关注(0)|答案(1)|浏览(163)

我正在尝试在我的docker中安装PowerShell社区扩展(需要获得Invoke-BatchFile):

FROM mcr.microsoft.com/windows/servercore:ltsc2022
[...]
RUN Install-Module Pscx -Scope CurrentUser -Confirm:$false -Force

上面的总是返回以下错误:

Install-NuGetClientBinaries : Exception calling "ShouldContinue" with "2" 
argument(s): "Object reference not set to an instance of an object."
At C:\Program 
Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1762 char:9
+         Install-NuGetClientBinaries -CallerPSCmdlet $PSCmdlet -Proxy  ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-NuGetClientBinaries], 
    MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException,Install-NuGetClientBinari 
   es

如何安装Pscx?由于PSCX不再通过Codeplex或作为MSI分发,而是仅在Powershell Gallery上分发,因此我无法使用chocolatey

2sbarzqh

2sbarzqh1#

事实证明,解决方案很简单:

RUN Install-PackageProvider -Name NuGet -Force
RUN Install-Module -Name Pscx -RequiredVersion 3.2.1.0 -Force -AllowClobber

在以下位置找到解决方案:

相关问题