0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PowerShell-7のインストールに沼った話

0
Posted at

こんにちは!今回は、Windows環境でPowerShell 5からPowerShell 7へアップグレードした際にハマってしまったポイントと、その解決策についてご紹介します。

沼の始まり:PowerShell 7をインストールしたはずが...

Microsoftの公式ドキュメント(PowerShell を Windows にインストールする)を参考に、wingetを使ってPowerShell 7をインストールしました。

PS
winget install --id Microsoft.PowerShell --source winget

インストール自体は問題なく完了。よし、これで最新版だ!と思い、いつも通りスタートメニューからPowerShellを起動しました。

しかし、$PSVersionTableでバージョンを確認してみると...

PS
$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.26100.4768
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.4768
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

バージョンが5のまま?

何度試しても結果は同じ。おかしいなと思って調べてみたところ、PowerShell 7はバージョン5のアップグレードではなく、全く別のアプリケーションとしてインストールされるということが判明しました。

沼からの脱出:PowerShell 7の起動方法

PowerShell 7が別アプリとしてインストールされているとなると、どこにあるのかを探さなければなりません。

スタートメニューから「PowerShell 7」と検索して、起動してみると...無事にバージョン7が起動しました!

PS
$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

私はバージョン5を使わない予定だったので、既存のターミナルでバージョン7を開くための設定をしようと考え、まずはそのパスを調べました。

私の環境では、以下のパスでした。

PowerShell 7 (今回インストールしたもの)
"C:\Program Files\PowerShell\7\pwsh.exe"

調べたパスをターミナルの設定から設定してあげると既定のターミナルとして起動してくれるようになります。

PowerShell 7は新しい機能がたくさん追加されていてとても便利です。まだ使っていない方は、ぜひこの機会に試してみてくださいね。

それでは、良いPowerShellライフを! 👋

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?