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

Is really PowerShell Direct tries to use PowerShell Core first? #7919

Closed
stknohg opened this issue Oct 2, 2018 · 3 comments
Closed

Is really PowerShell Direct tries to use PowerShell Core first? #7919

stknohg opened this issue Oct 2, 2018 · 3 comments
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Fixed The issue is fixed.

Comments

@stknohg
Copy link
Contributor

stknohg commented Oct 2, 2018

Related #6669, #7241.

I tried to the following feature of Powershell Core 6.1 on Windows Server 2019 insider.

PowerShell Direct is a feature of PowerShell and Hyper-V that allows you to connect to a Hyper-V VM without network connectivity or other remote management services.

In the past, PowerShell Direct connected using the inbox Windows PowerShell instance on the VM.
Now, PowerShell Direct first attempts to connect using any available pwsh.exe on the PATH environment variable. If pwsh.exe isn't available, PowerShell Direct falls back to use powershell.exe.

But, PowerShell Direct for VM always uses Windows PowerShell.

Here is a simple PoC code.

PS C:\> Get-ComputerInfo -Property OsName, OsVersion

OsName                                   OsVersion
------                                   ---------
Microsoft Windows Server 2019 Datacenter 10.0.17744


PS C:\> $PSVersionTable.PSVersion

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
6      1      0

PS C:\> $cred = Get-Credential administrator

# PowerShell Dicret for VM always uses Windows PowerShell.
PS C:\> Invoke-Command -VMName TestVM -ScriptBlock { $PSVersionTable.PSVersion } -Credential $cred

Major  Minor  Build  Revision PSComputerName
-----  -----  -----  -------- --------------
5      1      14393  0        TestVM

Of course, PowerShell Core 6.1 is installed in the TestVM.
In addition, I can use PowerShell Core 6.1 with PowerShell Direct by specifying the -ConfigurationName parameter

# PowerShell Direct for VM uses PowerShell Core with -ConfigurationName parameter.
PS C:\> Invoke-Command -VMName TestVM -ScriptBlock { $PSVersionTable.PSVersion } -Credential $cred -ConfigurationName 'PowerShell.6'

Major  Minor  Patch  PreReleaseLabel BuildLabel  PSComputerName
-----  -----  -----  --------------- ----------  --------------
6      1      0                                  TestVM

I read #7241 and some source code.

I think that this feature applies only to PowerShell Direct for Container.
PowerShell Direct for VM uses Hyper-V Socket to communicate a VM.

Is my recognition correct?


Note: I also tried to this feature to a container, but I failed because of #5794.

@iSazonov iSazonov added the Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a label Oct 2, 2018
@SteveL-MSFT
Copy link
Member

@stknohg this is a doc issue. Looking at the original code change, this only affects creating a PSSession to a Container. Submitted doc fix.

However, since we've standardized the ConfigurationName for PSCore6, we could change the VM path to try PowerShell.6 first then fallback to Microsoft.PowerShell (which defaults to Windows PowerShell)

@stknohg
Copy link
Contributor Author

stknohg commented Oct 7, 2018

@SteveL-MSFT
Thank you for clarifying. I understood.
I will close this Issue after the document is updated.


However, since we've standardized the ConfigurationName for PSCore6, we could change the VM path to try PowerShell.6 first then fallback to Microsoft.PowerShell (which defaults to Windows PowerShell)

Good idea.
However, I think we should discuss how to try and fallback when newer versions (e.g. PowerShell Core 7.0) come out.
We can discuss after it becomes necessary.

@SteveL-MSFT
Copy link
Member

Closing this issue as the doc change got merged. Please open a new issue if we want to consider trying different sessionconfigurations for VMs.

@SteveL-MSFT SteveL-MSFT added the Resolution-Fixed The issue is fixed. label Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Fixed The issue is fixed.
Projects
None yet
Development

No branches or pull requests

3 participants