PowerShell Core 7 インストール手順書 (MSI)

このサイトを検索 | Search this site

PowerShell Core バージョン 7.4.1

PowerShell を起動した際に、バージョン 7.4.1 のリリース通知があったので、winget によるアップデートを試みました。しかし、バージョン 7.4.0 がダウンロードされたため、GitHub から MSI を入手してアップデートしました。

バージョン 7.4.1 にアップデートした後、winget でもバージョン 7.4.1 が利用可能になったため、あと30分待てば winget からアップデートできたようです。少し損した気分です。

MSI を実行した際にスナップショットを撮影したので、インストール手順書としてまとめておきます。

クロスプラットフォーム

Windows 10/11 に搭載されているのは、Windows PowerShell 5.1.x です。これを「WPS」と呼びます。

WPS を起動すると、Windows の冠が取れたクロスプラットフォーム版 PowerShell Core 7 をインストールするよう勧められます。この記事では、クロスプラットフォームバージョンの PowerShell Core に焦点を当てています。



ソフトウェア情報

※記事より新しいバージョンが表示される場合があります。

WPSとPowerShell Core は共存できる

WindowsPowerShell

PowerShell Core は独立したプログラムとしてインストールされるため、WPSと共存させることができます。

PowerShell Core は、実行ファイルと参照するプロファイルがWPSと異なるため、独立したコマンドラインシェルとして動作します。

Vim の扱い

WPSのプロファイルには、vim.exe のフルパスを指定したエイリアスが設定されているため、PATHに含まれていなくても vim を実行できます。一方、PowerShell Core が使用するプロファイルはWPSとは別のフォルダーを参照するため、そのままでは Vim を実行できません。

対策としては、Core用のプロファイルを作成してエイリアスを設定するか、環境変数 PATH に vim.exe のフルパスを追記します。

PowerShell 5.1/7.x
バージョン表示名実行ファイル
PowerShell 5.1Windows PowerShellpowershell.exe
PowerShell 7.xPowerShell 7 (x64)pwsh.exe

PowerShell Core インストール手順書

Install

GitHubからMSIインストーラーを入手して PowerShell Core をインストールしたのでスナップショットを掲載します。

使用したファイル:PowerShell-7.4.1-win-x64.msi

デバイスの環境
OSWindows 11 23H2 64-bit
ファイルPowerShell-7.4.1-win-x64.msi

MSIインストーラーのダウンロード

Assets > Show all 30 assets(下方にあります)

[Show all 30 assets] を展開して PowerShell-7.4.1-win-x64.msi を探す。

ShowAll30assets

Welcome to the PowerShell 7-x64 Setup Wizard

The Setup Wizard will install PowerShell 7-x64 on your computer. Click Next to continue or Cancel to exit the Setup Wizard.

Nextをクリック

Welcom

Destination Folder

Click Next to install to the default folder or click Change to choose another.

PowerShell Core をインストールするターゲットフォルダーを選択する(Change... でフォルダー選択)

C:\Program Files\PowerShell\(既定値)

DestinationFolder

Optional Actions

Initialization and Customization
初期化とカスタマイズ

  • Add PowerShell to Path Environment Variable
    Path環境変数にPowerShellを追加する
  • Register Windows Event Logging Manifest
    Windowsイベントロギングマニフェストの登録
  • Enable PowerShell remoting
    PowerShellリモーティングを有効にする
  • Disable Telemetry (Reboot or Restart of processes may be required)
    テレメトリーを無効にする(プロセスの再起動またはリスタートが必要な場合があります)
  • Add 'Open here' context menus to Explorer
    エクスプローラーに「ここで開く」コンテキストメニューを追加
  • Add 'Run with PowerShell 7' context menu for PowerShell files
    PowerShellファイルのコンテキストメニューに「PowerShell 7で実行」を追加する
OptionalActions

Use Microsoft Update to help keep your computer secure and up to date

Microsoft Update helps keep your computer secure and up to date for Windows and other Microsoft products, including PowerShell 7. Updates will be delivered based on your current update settings. You can review or change these settings from the Windows Update control panel.

Microsoft Update は、PowerShell 7 を含む Windows やその他の Microsoft 製品について、お使いのコンピュータを安全かつ最新の状態に保つのに役立ちます。更新プログラムは、現在の更新プログラム設定に基づいて配信されます。これらの設定は、Windows Update コントロール パネルから確認または変更できます。

  • Enable updating PowerShell through Microsoft Update or WSUS (recommended)
    Microsoft UpdateまたはWSUSによるPowerShellのアップデートを有効にする(推奨)
  • Use Microsoft Update when I check for updates (recommended)
    アップデートを確認する際にMicrosoft Updateを使用する(推奨)
UseMicrosoftUpdate

Ready to install PowerShell 7-x64

Click Install to begin the installation. Click Back to review or change any of your installation settings. Click Cancel to exit the wizard.

[Install|Back|Cancel] 処理を選択してください。

5ReadyToInstall

ユーザーアカウント制御

インストーラーは管理者特権を要求しています

[はい] を選択

6uac

Installing PowerShell 7-x64

Please wait while the Setup Wizard installs PowerShell 7-x64.

処理が終わるまで待つ

Installing

Installation completed successfully.

Click the Finish button to exit the Setup Wizard.

Finishをクリック

InstallationCompleted

PowerShell Core を起動する方法

tweak

PowerShell Core はスタートメニューから起動することができます。

Windows ターミナルの設定を変更して、PowerShell を既定のプロファイルに設定することができます。

PowerShell Core 起動方法
  1. スタートメニューを開きます。
  2. 「PowerShell 7」を検索します。
  3. 「PowerShell 7」を起動します。
Windows ターミナルの設定を変更して、PowerShell を既定のプロファイルに設定することもできます。
  1. Windows ターミナルを開きます。
  2. タブバーから「設定」をクリックします。(>をクリック)
    PowerShell7_settings
  3. 「スタートアップ」> 「既定のプロファイル」を「PowerShell」に変更します。
  4. 「保存」をクリックします。
  5. 以上
    PowerShell7_profile

複数のインストール方法(Windows)

Guides

PowerShell Core は複数のインストール方法が提供されています。Winget を利用する方法が推奨されています。

  1. Winget - Windows クライアントに PowerShell をインストールする(推奨方法)
  2. MSI パッケージ- Windows サーバーおよびエンタープライズ展開シナリオに最適な選択肢
  3. ZIP パッケージ- 「サイドロード」または複数のバージョンをインストールする最も簡単な方法
  4. Windows Nano Server、Windows IoT、および Arm ベースのシステムにはこの方法を使用します。
  5. .NET グローバル ツール- 他のグローバル ツールをインストールして使用する .NET 開発者にとって良い選択肢です。
  6. Microsoft Store パッケージ- PowerShell のカジュアル ユーザー向けに簡単にインストールできる方法ですが、制限があります

その他のプラットフォーム

Linux、macOS、Arm のインストール方法は以下のリンクからお探しください。

PowerShell Core の新機能

WindowsPowerShell
出典:thomasmaurer.ch
[PowerShell Core 新機能(自動翻訳)]
  1. Out-GridView、-ShowWindow、およびその他の GUI コマンドレットが Windows に戻りました
  2. ForEach-Object -Parallel

    -Parallel パラメーターを ForEach-Object コマンドレットに追加すると、 PSWorkflowのオプションと同様に、スクリプトブロックを並列実行できます。

  3. PowerShell 7 での Windows PowerShell モジュールのインポート

    PowerShell Core 6 と互換性のない Windows PowerShell モジュールをインポートできるようになりました。

  4. クリップボードコマンドレット

    Get-ClipboardとSet-Clipboard はWindows、Linux、macOS で使用できます。

  5. Get-Counter (Windows パフォーマンス カウンター)
  6. Out-Printer (Windows)

    Out-Printerコマンドレットを使用すると、PowerShell オブジェクトをプリンターに送信できます (Windows のみ)。

  7. Clear-RecycleBin (Windows)

    Clear-RecycleBinコマンドレットを使用して Windows のごみ箱を空にできるようになりました。

  8. Test-Connection テスト接続

    Windows PowerShell と PowerShell 7 の間でより一貫したエクスペリエンスが提供されました。

  9. Null 代入演算子と合体演算子 (?? および ??=)
  10. Get-Hotfix ホットフィックスの入手 (Windows)

    Get-Hotfix は、ローカルまたはリモート コンピューターにインストールされている修正プログラムと更新プログラムを取得します。

  11. Select-String による強調
  12. ConciseView による新しいエラー ビュー

    エラー用の新しい ConciseView

  13. 新しい Get-Error コマンドレット
  14. パイプライン チェーン演算子 (&& および ||)
  15. 三項演算子
  16. PowerShell Desired State Configuration (DSC) の改善 (実験的)
  17. 長期保守サービス

    PowerShell 7 は、 .NET Core 3.1がサポートされている限りサポートされます。

参考:wingetコマンドのエラーメッセージ

PC_programming

wingetコマンドで PowerShell Core をインストールする際に、エラーメッセージ「既存のパッケージが既にインストールされています。」が表示される場合があります。これは、古いバージョンの PowerShell Core がデバイスに存在することを通知しています。

既存の PowerShell Core をアンインストールすることで、新しいバージョンの PowerShell Core をインストールすることができます。

    手順

  1. PowerShell コマンドプロンプトで、以下のコマンドを実行して既存の PowerShell をアンインストールします。

    PS C:\> winget uninstall PowerShell

  2. PowerShell コマンドプロンプトで、以下のコマンドを実行して 7.x をインストールします。

    PS C:\> winget install --id Microsoft.Powershell --source winget

  3. 以上
Windows PowerShell
ps_wtps_wt_right
PS C:\> winget install --id Microsoft.Powershell --source winget
既存のパッケージが既にインストールされています。インストールされているパッケージ...をアップグレードしようとしています
新しいバージョンが見つかりましたが、インストールテクノロジが現在インストールされているバージョンと異なります。パッケージをアンインストールして、新しいバージョンをインストールしてください。

PS C:\> winget uninstall PowerShell
見つかりました PowerShell [Microsoft.PowerShell]
パッケージのアンインストールを開始しています...
██████████████████████████████ 100%
正常にアンインストールされました

PowerShell Core 7 をインストールする方法

PowerShell Core 7 インストール手順書 (winget)

Windows 専用の PowerShell 5.1 に対し、クロスプラットフォームで利用できる PowerShell 7 が登場。機能強化や新機能搭載で、PowerShell の可能性を広げる。wingetによるインストール方法を解説します。

まとめ

matome
reload
  • MSIによる PowerShell Core バージョン 7.4.1 インストール手順書
  • wingetでアップデートできなかったのでMSIを入手してアップデートしたが、現在はwingetからバージョン7.4.1にアップデート可能になっている。
  • Windows 10/11 に搭載されているのは、Windows PowerShell 5.1.xxx。この記事は [Windows] の冠がとれたクロスプラットフォーム版の PowerShell Core を対象にしている。
  • PowerShell Core 7.x は Windows PowerShell 5.1 と共存させることができる。
  • PowerShell Core は Windows、Linux、macOS、Arm の各プラットフォームで利用することができる。
  • WPS | SC2
DISMを使用してドライバーをバックアップする方法 (Windows 10/11)

DISMを使用してドライバーをバックアップする方法 (Windows 10/11)

Windowsの標準機能でデバイスドライバのバックアップが実現できます。デバイスドライバは、Windowsとデバイスの橋渡しをするソフトウェアです。OEMドライバはメーカーが独自に開発したドライバで、デバイス固有の機能を実現します。

SC2
ブログサークルSNS
クリックして応援してね!
人気ブログランキングPVアクセスランキング にほんブログ村ブログランキング・にほんブログ村へ

このサイトを検索 | Search this site

コメントを投稿

0 コメント