以下ページで内容更新しました
PowerShell 6.0 on CentOS 7
http://www.vwnet.jp/Windows/PowerShell/2018012401/PS6onCent7.htm
PowerShell が OSS になって on Linux で動くようになりました。
とはいっても、まだ alpha なので今後が期待といった感じなのですが、やはり試してみたいですよね。
物理マシンを準備するのも大変なので、Hyper-V VM に CentOS 7 をインストールして、こいつに PowerShell をインストールしてみます。
今回は、Windows Server 2016 TP5 Hyper-V VM に 英語環境の CentOS 7
をインストールします。
(WS12R2 Hyper-V でも同様です)
Ubuntu と OSX のインストールは MS エバンジェリストの Miho さんが書かれているので、そちらをどうぞ
PowerShell on Linux (Ubuntu16.4) のインストール方法 – Miho’s
exceptional item
https://docs.microsoft.com/ja-jp/archive/blogs/miyamam/howtoinstallpsonubuntu?WT.mc_id=WD-MVP-36880
PowerShll on OSX 10.11 のインストール – Miho’s exceptional item
https://docs.microsoft.com/ja-jp/archive/blogs/miyamam/psonosx?WT.mc_id=WD-MVP-36880
まずは、CentOS 7 の ISO ダウンロードですね。
以下のサイトから ISO ファイルをダウンロードします。
CentOS Project
https://www.centos.org/
ISO ファイルをダウンロードしたら、Gen1 か、セキュアブートを OFF にした Gen2 で VM を作ります。
WS12R2 の場合は、メモリーサイズを 1024MB にしておくと良いでしょう。
CentOS のインストールはわかっているって方は、PowerShell をインストールする に進んでください。
Install CentOS 7 を選択

日本語環境にすると、文字表示が正しくされないので英語環境がおすすめです
英語キーボードで記号がうまく入力できない場合は、ここにキーマップ書いていますので参考にしてください。
英語キーボート認識される問題の回避方法
http://www.vwnet.jp/Windows/w8/EnglishKeybord/EnglishKeyLayout.htm

INSTALLATION SOUSE と SOFTWARE SELECTION に黄色の三角が付いていますが、これは少しすると消えるので、INSTALLATION DESTINATION を設定します。

ディスクは選択済みになっているので、そのまま Done

ネットワークが接続されていないので設定

eth0 を ON に

インストール開始

root パスワードを設定

パスワードを入力

インストールが完了したら Reboot

VM が起動したらログインして ip addr で IP アドレスを確認します。
(CentOS 7 には
ifconfig が標準で入っていないってのをこの時初めて知りました w)
systemctl status sshd.service を見ると、default で sshd が稼働しているようです。
念のために、firewall-cmd --list-all でファイアウオールを確認すると ssh 開いていますね。

ssh が有効になっているので Tera Term 等の ssh cleint で CentOS に接続します。
Windows 10 1607 な方は bash on Windows で ssh するのも良いかも
ssh で接続する場合は、「root@IPアドレス」で接続します。

PowerShell install パッケージは最新版に更新されている可能性があるので、以下 github から最新パッケージの URL を取得します。
PowerShell/README.md at master · PowerShell/PowerShell ·
GitHub
https://github.com/PowerShell/PowerShell/blob/master/README.md

CentOS 7 に PowerShell をインストールには yum install を使います。
sudo yum install https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.9/powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm

インストールが完了すると、powershell コマンドで PowerShell が起動します。(PowerShell プロンプトが少し buggy な動きするので Tera Term)

コマンドレット数は 345 と控えめですが、Nano Server と同様に PowerShell Core は基本的なコマンドレットはサポートされています。
管理用の CentOS 7 から、Windows Server を操作するシナリオで CentOS 7 から Windows Server へ Enter-PSSession してみましたが、今のバージョンでは Enter-PSSession がサポートされていないようで、PowerShell が落ちてしまいました。(キャプチャー撮り損ね)
PS /root> Enter-PSSession dc01 -Credential vwnet\mura
Windows PowerShell credential request
Enter your credentials.
Password for user vwnet\mura: *********
Enter-PSSession : Unable to load DLL 'libpsrpclient': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)
At line:1 char:1
+ Enter-PSSession wstp5 -Credential vwnet\mura
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Enter-PSSession], DllNotFoundException
+ FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell.Commands.EnterPSSessionCommand
PS /root>
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Management.Automation.Remoting.PrioritySendDataCollection.Clear()
at System.Management.Automation.Remoting.Client.BaseClientTransportManager.CloseAsync()
at System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager.CloseAsync()
at System.Management.Automation.Remoting.Client.BaseClientTransportManager.Finalize()
Aborted
|
Windows から CentOS 7 の PoewrShell が叩けるかと Enable-PSRemoting しようとしたら、コマンドレットがないようなので、これも無理っぽですかね?
Windows 10 PowerShell と PowerShell on Linux の違い
http://www.vwnet.jp/Windows/PowerShell/Windows10PowerShellvsPowerShellonLinux.htm
![]()
![]()
Copyright © MURA All rights reserved.