PowerShell import module in docker fails with errormodule is not currently supported on the Core edition of PowerShell

PowerShell import module in docker fails with errormodule is not currently supported on the Core edition of PowerShell

In repsonse to your query – to do this programmatically using Powershell you could try something like this BEFORE you Import-Module:

RUN pwsh -c (Get-Module VMware.PowerCLI -ListAvailable).RequiredModules | Where-Object { $_.Name -eq VMware.VimAutomation.HorizonView } | Uninstall-Module

Edit: Ok this won;t work.

What you could do is only import the modules you need:

# Generally most stuff needs the core module:
RUN pwsh -Command Import-Module -Name VMware.VimAutomation.Core -Scope CurrentUser

# If for example you need to manipulate storage, also import that module
RUN pwsh -Command Import-Module -Name VMware.VimAutomation.Storage -Scope CurrentUser

The full list of available modules is in the VMware.PowerCLI.psd1 file. The advantage of this also is that it will be faster as you won;t be importing ALL the commands, only the ones you need to use.

PowerShell import module in docker fails with errormodule is not currently supported on the Core edition of PowerShell

Leave a Reply

Your email address will not be published.