1

I am trying to install PowerShell Community Extensions (required to get Invoke-BatchFile) within my docker:

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

The above always returns with the following error:

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

How is one supposed to install Pscx ? Since PSCX is no longer distributed via Codeplex or as an MSI, but only on the Powershell Gallery I cannot use chocolatey.

malat
  • 12,152
  • 13
  • 89
  • 158

1 Answers1

1

Turns out that the solution is simply:

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

Solution was found at:

malat
  • 12,152
  • 13
  • 89
  • 158