-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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.