Skip to content
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

Minimum PowerShell Host Version Error #2198

Closed
stvpwrs opened this issue Aug 10, 2022 · 6 comments · Fixed by #2257
Closed

Minimum PowerShell Host Version Error #2198

stvpwrs opened this issue Aug 10, 2022 · 6 comments · Fixed by #2257
Labels

Comments

@stvpwrs
Copy link

stvpwrs commented Aug 10, 2022

When trying to run a script with the Microsoft.Xrm.Data.Powershell module I get the following error:

The current PowerShell host is: '.NET Interactive Host' (version 0.0.1). The module 'C:\Users\...\Documents\PowerShell\Modules\Microsoft.Xrm.Data.Powershell\2.8.14\Microsoft.Xrm.Data.Powershell.psd1' requires a minimum PowerShell host version of '1.0' to run.

I'm not sure if this is an issue with how this module is checking the PowerShell version or something unexpected with the new .NET Interactive Host.

@jonsequitur
Copy link
Contributor

Could you provide example code that reproduces this issue?

Thanks.

@stvpwrs
Copy link
Author

stvpwrs commented Sep 6, 2022

The following code will produce the error.

$forMicrosoftXrmDataPowershell = @{
    Force           = $true
    Name            = 'Microsoft.Xrm.Data.Powershell'
    RequiredVersion = '2.8.14'
}
Import-Module @forMicrosoftXrmDataPowershell
Import-Module: 
Line |
   6 |  Import-Module @forMicrosoftXrmDataPowershell
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The current PowerShell host is: '.NET Interactive Host' (version 0.0.1).

@jonsequitur
Copy link
Contributor

@daxian-dbw Can you provide some insights here? Thanks!

@daxian-dbw
Copy link
Contributor

The module manifest of Microsoft.Xrm.Data.Powershell defines PowerShellHostVersion = '1.0', and that means it requires the host to be version 1.0. But the .NET Interactive Host is currently v0.0.1. A quick fix would be to simply change it to 1.0.0, at https://github.com/dotnet/interactive/blob/main/src/Microsoft.DotNet.Interactive.PowerShell/Host/PSKernelHost.cs#L25.

@jonsequitur
Copy link
Contributor

Does that change any behaviors of the host?

@daxian-dbw
Copy link
Contributor

daxian-dbw commented Sep 6, 2022

I don't think so. That version was chosen probably just to reflect it was new work. However, changing the version itself may not solve all the problems -- this module depends on the host version being 1.0, but there could be other modules depending on a higher version of the host -- those modules were targeting PowerShell console (thus the PowerShell console host) and ideally should remove that key from the module manifest file unless it really depends on the PowerShell console host.

jonsequitur added a commit to jonsequitur/interactive that referenced this issue Sep 13, 2022
@colombod colombod linked a pull request Sep 13, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants