Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

powershell.exe started from pwsh.exe give preference to pwsh modules and fails module version compatiblity check #7324

Copy link
Copy link
@adityapatwardhan

Description

@adityapatwardhan
Issue body actions

Windows PowerShell started from a pwsh.exe from preview.4 gives preference to pwsh module path.
As an effect, module load fails with Modules_InsufficientPowerShellVersion,Microsoft.PowerShell.Commands.ImportModuleCommand

Steps to reproduce

PS D:\> powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS D:\> Write-Verbose "Test" -verbose
Write-Verbose : The 'Write-Verbose' command was found in the module 'Microsoft.PowerShell.Utility', but the module could not be loaded. For more information, run 'Import-Module
Microsoft.PowerShell.Utility'.
At line:1 char:1
+ Write-Verbose "Test" -verbose
+ ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Write-Verbose:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

PS D:\> Import-Module Microsoft.PowerShell.Utility
Import-Module : The version of Windows PowerShell on this computer is '5.1.18200.1000'. The module 'C:\program
files\powershell\6-preview\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1' requires a minimum Windows PowerShell version of '6.1' to run. Verify that you have the minimum
required version of Windows PowerShell installed, and then try again.
At line:1 char:1
+ Import-Module Microsoft.PowerShell.Utility
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (C:\program file...ll.Utility.psd1:String) [Import-Module], InvalidOperationException
    + FullyQualifiedErrorId : Modules_InsufficientPowerShellVersion,Microsoft.PowerShell.Commands.ImportModuleCommand

Workaround
After starting Windows PowerShell adjust the PSModulePath

$env:Psmodulepath = "C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;$env:PSModulePath"

cc @rjmholt

Expected behavior

Write-Verbose should work

Actual behavior

Modules_InsufficientPowerShellVersion,Microsoft.PowerShell.Commands.ImportModuleCommand

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0-preview.4
PSEdition                      Core
GitCommitId                    6.1.0-preview.4
OS                             Microsoft Windows 10.0.18200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core modulecmdlets in the Microsoft.PowerShell.Core module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.