目次
文書の過去の版を表示しています。
PowerShell(Linux)
PowerShell - Windows
本家: PowerShell Documentation | Microsoft Docs
ソースコード: GitHub - PowerShell/PowerShell: PowerShell for every system!
インストール
Releases · PowerShell/PowerShell
https://aka.ms/pscore6
https://aka.ms/pscore6-docs
https://aka.ms/powershell
Fedora - dnf
Fedora への PowerShell のインストール - PowerShell | Microsoft Docs
# Register the Microsoft signature key sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc # Register the Microsoft RedHat repository curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo # Update the list of products sudo dnf check-update # Install a system component sudo dnf install compat-openssl10 # Install PowerShell sudo dnf install -y powershell # Start PowerShell pwsh
$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
$ cat /etc/redhat-release
Fedora release 31 (Thirty One)
2020/08/30 現在 https://packages.microsoft.com/fedora/31/prod/ に PowerShell が存在していないので Fedora 30 の packages-microsoft-com-prod (https://packages.microsoft.com/fedora/30/prod/) からインストールを行う。
$ curl https://packages.microsoft.com/config/fedora/30/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 195 100 195 0 0 454 0 --:--:-- --:--:-- --:--:-- 453 [packages-microsoft-com-prod] name=packages-microsoft-com-prod baseurl=https://packages.microsoft.com/fedora/30/prod/ enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc
$ sudo dnf install powershell
packages-microsoft-com-prod 608 kB/s | 760 kB 00:01 メタデータの期限切れの最終確認: 0:00:01 時間前の 2020年08月30日 17時51分53秒 に実施しました。 依存関係が解決しました。 ============================================================================================================ Package Architecture Version Repository Size ============================================================================================================ インストール: powershell x86_64 7.0.3-1.rhel.7 packages-microsoft-com-prod 55 M トランザクションの概要 ============================================================================================================ インストール 1 パッケージ ダウンロードサイズの合計: 55 M インストール済みのサイズ: 151 M これでよろしいですか? [y/N]: y パッケージのダウンロード: powershell-7.0.3-1.rhel.7.x86_64.rpm 9.5 MB/s | 55 MB 00:05 ------------------------------------------------------------------------------------------------------------ 合計 9.5 MB/s | 55 MB 00:05 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 インストール中 : powershell-7.0.3-1.rhel.7.x86_64 1/1 scriptletの実行中: powershell-7.0.3-1.rhel.7.x86_64 1/1 検証 : powershell-7.0.3-1.rhel.7.x86_64 1/1 インストール済み: powershell-7.0.3-1.rhel.7.x86_64 完了しました!
PowerShell の実行
$ pwsh
Release Candidate 版の場合
$ pwsh-preview
PowerShell のバージョン
$ Get-Host
Name : ConsoleHost Version : 7.0.0-rc.2 InstanceId : 546f330c-e929-4775-8001-43778f6ce1c7 UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : ja-JP CurrentUICulture : ja-JP PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy DebuggerEnabled : True IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace
$ Get-Host | Select-Object Version
Version ------- 7.0.0-rc.2
$ $PSVersiontable
Name Value ---- ----- PSVersion 7.0.0-rc.2 PSEdition Core GitCommitId 7.0.0-rc.2 OS Linux 5.4.17-200.fc31.x86_64 #1 SMP Sat Feb 1 19:00:13 UTC 2020 Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0