简体   繁体   中英

Run Powershell Core from Powershell 5 remote pc

I've installed Powershell Core on a remote PC.

I've entered into a remote session with Powershell 5 to that PC.

When i run

PowerShell -NoExit "pwsh-preview" or just pwsh-preview

it shows Powershell 7 intro and exits again to PS5 (see screenshot below)

在此处输入图片说明

You're not showing how you are validating that this is happening.

All you are showing is the prompt return.

Start your session, then $PSVersionTable, then type pwsh, then type $PSVersionTable again.

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.18362.628
PSEdition                      Desktop
PSCompatibleVersions           {...                                                                                 

pwsh

PowerShell 6.2.4
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS D:\Scripts> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.2.4
PSEdition                      Core
GitCommitId                    6.2.4
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {...

PS D:\Scripts> exit

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.18362.628
PSEdition                      Desktop
PSCompatibleVersions           {...

You could easily change your profile to show you on your prompt what version you are in, as you switch between them.

As per your comment.. .

there is no command like "pwsh" only pwsh-preview PSVersion 5.1.17763.771

Your statement is incorrect. that above screen output is the exact output from my system running the latest release of Powershell v7.

I am not new to this. I've been using PowerShell since before it was called PowerShell as an alpha user and insider.

Monad Manifesto – the Origin of Windows PowerShell

Here are the properties from the shortcut that gets created on installation.

Shortcut title

'PowerShell 6 (x64)' ---

shortcut path "C:\\Program Files\\PowerShell\\6\\pwsh.exe" -WorkingDirectory ~

You are running an earlier preview and I am running current release. Hence the difference.

在此处输入图片说明

https://github.com/PowerShell/PowerShell/releases

PowerShell-6.2.4-win-x64.msi

PowerShell-6.2.4-win-x64.msix

PowerShell-6.2.4-win-x64.zip

PowerShell-6.2.4-win-x86.msi

PowerShell-6.2.4-win-x86.zip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM