Skip to content

PowerShell integrated Console - version no. #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rebornix opened this issue Mar 22, 2017 · 13 comments
Closed

PowerShell integrated Console - version no. #599

rebornix opened this issue Mar 22, 2017 · 13 comments
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@rebornix
Copy link

From @lw-schick on March 22, 2017 13:4

Description

I can't import the PowerShell module SSASCMDLETS from SQL Server Analytics Service.

Steps to Reproduce:

  • VSCode Version: 1.10.2
  • OS Version: Windows 7 64x
  1. Install SQL Server with Analytics Service
  2. Run Import-Module SSASCMDLETS

Results in:

PS C:\myfolder> Import-Module SQLASCMDLETS
Import-Module : The current Windows PowerShell host is: 'Visual Studio Code Host' (version 0.10.1). The module 'C:\Program Files (x86)\Microsoft SQL
Server\110\Tools\PowerShell\Modules\SQLASCMDLETS\SQLASCMDLETS.psd1' requires a minimum Windows PowerShell host version of '1.0' to run.
At line:1 char:1
+ Import-Module SQLASCMDLETS
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (C:\Program File...LASCMDLETS.psd1:String) [Import-Module], InvalidOperationException
    + FullyQualifiedErrorId : Modules_InsufficientPowerShellHostVersion,Microsoft.PowerShell.Commands.ImportModuleCommand

PS C:\myfolder>

The PSVersionTable looks OK:

PS C:\myfolder> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.0.10586.117
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10586.117
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\myfolder>

Copied from original issue: microsoft/vscode#23017

@rebornix
Copy link
Author

It's very likely a Powershell issue, please file against the powershell extension you are using :)

@daviwil
Copy link
Contributor

daviwil commented Mar 22, 2017

This seems like an unnecessary limitation of the SQL module, it is throwing an error because the $host.Version reported inside of the Integrated Terminal is below 1.0. I'm reluctant to bump our host version to 1.0 just to make the SQL module happy but I doubt they'd be able to respond to this in the short term to unblock you. I'll fix it for 0.11.0, coming out later today.

@daviwil daviwil added the Issue-Bug A bug to squash. label Mar 22, 2017
@daviwil daviwil added this to the 0.11.0 milestone Mar 22, 2017
daviwil added a commit that referenced this issue Mar 22, 2017
Fix #599: SSASCMDLETS module cannot be loaded
@lw-schick
Copy link

Thanks @daviwil

@daviwil
Copy link
Contributor

daviwil commented Mar 23, 2017

@lw-schick did the 0.11.0 update fix it for you?

@lw-schick
Copy link

Yes:

Starting PowerShell...

PS C:\git\OlapDbMetaData> Import-Module SQLASCMDLETS
PS C:\git\OlapDbMetaData>

now all is fine

@daviwil
Copy link
Contributor

daviwil commented Mar 23, 2017

Great, thanks for confirming!

@szhivotovsky
Copy link

Ran across this closed case. I'm running into the same issue with a different module. I'm on v0.12.2.

import-module : The current Windows PowerShell host is: 'Visual Studio Code Host' (version 1.0.0). The module
'/usr/local/microsoft/powershell/6.0.0-alpha.18/Modules/Okta-PSModule-master/Okta.psd1' requires a minimum Windows PowerShell host version of '3.0' to run.
At line:1 char:1

PS /usr/local/microsoft/powershell/6.0.0-alpha.18/Modules> $host

Name : Visual Studio Code Host
Version : 1.0.0

Can anything be done here? Thanks!

@daviwil
Copy link
Contributor

daviwil commented May 9, 2017

@szhivotovsky Do you know why the module is looking for a specific host and host version? That seems like a bad idea in general because it prevents that module from being loaded in any other host. Can you ask the module author to loosen their check?

@vikashdaya
Copy link

vikashdaya commented Mar 22, 2018

@szhivotovsky ... found this while looking for the same issue.
If you change the version of the host in the Okta.psd1 file to 1.0, the module with load and work...

Minimum version of the Windows PowerShell host required by this module
PowerShellHostVersion = '1.0'

@jschmitter
Copy link

jschmitter commented Aug 16, 2018

@daviwil Are you saying that to use the vs code powershell debugger I need to make all my powershell modules backwards compatible with PowerShell v 1? I must be misunderstanding something.

I'm experiencing the same issue, and definitely can't decrease the minimum version of my powershell modules. Is there a way I can increase the $host.Version?

@TylerLeonhardt
Copy link
Member

@jschmitter

backwards compatible with PowerShell v1?

that's not quite right. The version of PowerShell itself, and the version of the host represents 2 different things.

A good example of this is... Open actual pwsh.exe (or powershell.exe) and type $Host.Version. Then open the vscode PowerShell extension's PowerShell Integrated Console and to the same. They're different - yet both are using the same version of PowerShell.

The "host version" is just the version of the thing that's giving you access to PowerShell otherwise known as the host.

There's a line of code in the extension that sets the host version. As David said before, we don't necessarily want to have to change this just for a specific module to work...

What do your modules want it to be set to?

@SeeminglyScience
Copy link
Collaborator

@jschmitter PowerShellHostVersion does not refer to the PowerShell version, it refers the version of the external host stored by $Host. In a normal session this is typically the engine's host ConsoleHost. However, other applications can supply their own PSHost implementations to supply custom logic for things like prompting the user.

Honestly the idea of manifest field PowerShellHostVersion would only make sense if it wasn't possible to write a custom host, or if the intention when using it is to target a specific custom host only. PowerShellHostVersion just shouldn't be used unless you are explicitly not supporting custom hosts, which I can't think of a reason to do.

If you are aiming to declare a minimum version of PowerShell, use PowerShellVersion instead.

@rjmholt
Copy link
Contributor

rjmholt commented Aug 16, 2018

For reference, our host version is the extension version:

this.hostVersion =
vscode
.extensions
.getExtension("ms-vscode.PowerShell")
.packageJSON
.version;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

9 participants