Repository navigation
Description
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 TestVMOf 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 TestVMI 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.
Activity
SteveL-MSFT commentedon Oct 5, 2018
Takuya Shibata (@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.6first then fallback toMicrosoft.PowerShell(which defaults to Windows PowerShell)stknohg commentedon Oct 7, 2018
Steve Lee (@SteveL-MSFT)
Thank you for clarifying. I understood.
I will close this Issue after the document is updated.
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 commentedon Oct 8, 2018
Closing this issue as the doc change got merged. Please open a new issue if we want to consider trying different sessionconfigurations for VMs.