35
PowerShell 10年間 ふりかえり 2016/12/17 CLR/H #103 ~ クリスマス オブ ザ デッド ~ 素敵なおひげ

PowerShell 10年間ふりかえり

Embed Size (px)

Citation preview

PowerShell 10年間ふりかえり

2016/12/17 CLR/H #103 ~ クリスマス オブ ザ デッド ~

素敵なおひげ

自己紹介

素敵なおひげ◦Twitter - @stknohg◦Blog - http://stknohg.hatenablog.jp/

何者?◦ CLR/HとJAZUG札幌(きたあず)の裏方

◦Microsoft MVPCloud and Datacanter Management (2016/07 - )

2

祝!PowerShell 10周年 PowerShell 10 Year Anniversary

◦ https://channel9.msdn.com/Events/PowerShell-Team/PowerShell-10-Year-Anniversary

3

アジェンダ

1. PowerShell 10年間ふりかえり

2.これからのPowerShell

3.誰のためのPowerShell

4

1. PowerShell 10年間ふりかえり

5

PowerShellとは

6

PowerShellは、WindowsおよびWindows Server用の自動化プラットフォームおよびスクリプト言語で、システムの管理を簡素化できます。他のテキストベースのシェルとは異なり、PowerShellは.NET Frameworkの機能を活用し、豊富なオブジェクトと、Windows環境を制御するための大量の組み込み機能を提供します。

https://msdn.microsoft.com/en-us/powershellの記述より引用

PowerShellの歴史

2006/11/14

• PowerShell 1.0リリース

2009/09/01

• PowerShell 2.0を搭載したWindows 7リリース(RTMは2009/07)

2009/10/26

• Windows Management Framework (WMF) 2.0リリース

7

PS1.0 PS2.0

• .NET Framework 2.0上で稼働• 標準搭載のOSは無し

• .NET Framework 2.0上で稼働• Windows Management Frameworkに統合

※OSのリリース日に関してはボリュームライセンス版のリリース日を基準としています

PowerShellの歴史

2012/09/01

• PowerShell 3.0を搭載したWindows 8リリース(RTMは2012/08)

2012/09/06

• WMF 3.0リリース

2013/10/18

• PowerShell 4.0を搭載したWindows 8.1/Windows Server 2012 R2リリース

2013/10/24

• WMF 4.0リリース

8

PS3.0 PS4.0

• .NET Framework 4上で稼働* Dynamic Language Runtime(DLR)の採用

• 過去バージョンはside by sideで実行可能に• .NET Framework 4.5上で稼働• Desire State Configuration(DSC)の登場

※OSのリリース日に関してはボリュームライセンス版のリリース日を基準としています

PowerShellの歴史

2015/07/29

• PowerShell 5.0を搭載したWindows 10リリース

2016/02/24

• WMF 5.0最終リリース(初回リリースは2015/12)

2016/08/02

• PowerShell 5.1を搭載したWindows 10 Anniversary Update(RS1)リリース

2017/01

• WMF 5.1リリース(予定)

9

PS5.0 PS5.1

• .NET Framework 4.5上で稼働• PackageManagementによるパッケージ管理• PSReadline、PesterなどのOSSの採用

• .NET Framework 4.6上で稼働• Core Editionの登場(Nano Server)

* .NET Core 上で稼働

※OSのリリース日に関してはボリュームライセンス版のリリース日を基準としています

PowerShellふりかえり 対応OS

10

https://msdn.microsoft.com/en-us/powershell/wmf/5.1/compatibility より引用

PowerShellふりかえり コマンド数(Function, Cmdlet)の推移

11

163366

11531346 1433

1644

0

200

400

600

800

1000

1200

1400

1600

1800

PS 1.0 PS 2.0 PS 3.0 PS 4.0 PS 5.0 PS 5.1

※1 各OSのインストール+Windows Update実施後の状態でコマンド数を計測※2 環境によって実際のコマンド数は変わるため、本グラフの値はあくまで参考値となります

> Get-Command -CommandType Function,Cmdlet | Measure-Object | Select-Object Count

Windows Server2003 R2

Windows Server2008 R2

Windows Server2012

Windows Server2012 R2

Windows Server2016

Windows Server2012 R2

PowerShellふりかえり

主要機能

• .NET Frameworkのオブジェクトを利用した型システム

• Extended Type System

• Adapted Type System

• オブジェクトパイプライン

• プロバイダー・ドライブ

• コマンドレット

• スナップイン

• 関数

• エイリアス

• などなど…

12

PowerShell 1.0の主要機能

PowerShellふりかえり

言語機能

•高度な関数

•例外処理(Try-Catch)

•モジュール

•スプラッティング

基盤関連

• PowerShell Remoting

•バックグラウンドジョブ

• トランザクション

開発環境

• Windows PowerShell Integrated Scripting Environment (ISE)

13

PowerShell 2.0の主な新機能

PowerShellふりかえり

言語機能

• 新しい演算子の追加 (ビットシフト、-in、-notin)

• 非配列オブジェクトに対するCountプロパティ

• ForEach-Object/Whre-Objectの簡易記法

基盤関連

• 実行基盤が.NET 2.0から.NET 4に

• PowerShellエンジンの改善

• ワークフロー

• スケジュールジョブ

• モジュールの自動検索

• PowerShell Web Access

開発環境

• ISEの改良

14

PowerShell 3.0の主な新機能

PowerShellふりかえり

言語機能

• コレクションに対するWhere()、ForEach()メソッド

• Dynamic Method

• PipelineVariableパラメーター

基盤関連

• PowerShell Desired State Configuration(DSC)

• 既定の実行ポリシーの変更(サーバーのみ)

• ワークフローの機能強化

開発環境

• デバッガの機能強化

15

PowerShell 4.0の主な新機能

PowerShellふりかえり

言語機能

• Class構文の導入

• Enum構文の導入

基盤関連

• DSCの機能強化

• PackageManagement、PowerShellGet

• PSReadlineやPesterといったOSSの採用

監査・セキュリティ

• Just Enough Administration(JEA)

• トレース機能の強化

開発環境

• リモートデバッグ機能の強化

• ISEでのTranscriptionのサポート

16

PowerShell 5.0の主な新機能

PowerShellふりかえり

言語機能

• using moduleステートメントのバージョン指定

•ファイルリダイレクトの非ハードコード化

基盤関連

• Core Editionの登場(Nano Server向け)

• DSCの機能強化

•パフォーマンス改善

•起動時のps1xml読み込みの廃止

• VT100サポート

監査・セキュリティ

•カタログコマンドレット

17

PowerShell 5.1の主な新機能

独断と偏見による総括

PowerShell 1.0~3.0

•機能強化の期間

PowerShell 4.0

• DSCによるプロビジョニングツールとしての進化

PowerShell 5.0

• PSReadlineやPesterなどのOSSを積極採用

• PackageManagement、PowerShellGetによるパッケージエコシステム

PowerShell 5.1

• Core Editionによるサポートプラットフォームの拡大

18

2. これからのPowerShell

19

PowerShell for every system!

20

PowerShell for every system! 2016/08/18、突如

PowerShellがオープンソースに

ソースはGitHubで公開◦ https://github.com/PowerShell/PowerShell

同時に.NET Coreを基盤としたクロスプラットフォーム化

◦対応プラットフォームLinux (Ubuntu 14.04、 Ubuntu 16.04、 CentOS 7)

MacOS 10.11

Windows 7、Windows 8.1/Windows Server 2012 R2~

21

PowerShell 6.0

OSS化したPowerShellのバージョンは6.0◦現在はアルファ版

◦ 2016/12/17時点でAlpha 14

機能に関してはCore EditionからWindowsに特化した部分を除外したイメージ

◦まだまだ足りない部分がある

◦コマンド数 (Function + Cmdlet)Windows 10 : 456

Ubuntu 16.04 : 349

22

PowerShell 6.0 対応プラットフォームとエディション

現在はCore Editionのみバイナリ配布◦デスクトップ版に関してどうなるかは不明

マイルストーンおよびリリース時期は不明

23

プラットフォームDesktop Edition

(.NET Framework)Core Edition(.NET Core)

Windows △ *バイナリ未配布 〇

Windows (Nano Server) × △ *インストーラー無し

Linux × 〇

Mac × 〇

これからのPowerShell

コミュニティからのフィードバックを重視

1. GitHub上でのIssue管理

2. Gitter、Slack上のチャットルーム

3. PowerShell-RFC◦GitHubでRFCにより新機能を議論https://github.com/PowerShell/PowerShell-RFC

4. ドキュメント管理◦GitHubでドキュメント管理。プルリク可能https://github.com/PowerShell/PowerShell-Docshttps://github.com/PowerShell/powerShell-Docs.ja-jp

24

これからのPowerShell 各ベンダー・サービスのCore Edition対応

1. Azure - AzureRM.NetCore.Preview (プレビュー版) https://www.powershellgallery.com/packages/AzureRM.NetCore.Preview/

https://blogs.technet.microsoft.com/jessicadeen/azure/getting-started-with-powershell-core-and-azurerm-modules-on-ubuntu-and-os-x/

2. AWS - AWSPowerShell.NetCore (ベータ版) https://www.powershellgallery.com/packages/AWSPowerShell.NetCore/

https://aws.amazon.com/jp/blogs/developer/introducing-aws-tools-for-powershell-core-edition/

3. GCP - CLOUD TOOLS FOR POWERSHELL (Ver. 1.0.0.1) https://github.com/GoogleCloudPlatform/google-cloud-powershell/

http://googlecloudplatform-japan.blogspot.jp/2016/12/1-powershell-windows-linux.html

4. Vmware - PowerCLI Core (Ver. 1.0) https://labs.vmware.com/flings/powercli-core

5. Docker - PowerShell Module for Docker (アルファ版) https://github.com/Microsoft/Docker-PowerShell

25

独断と偏見による予測

1. 機能面◦機能面ではPowerShellは成熟してきた今後はセキュリティ面での強化が多くなる、かも?

◦RFCも新機能より既存機能の改善案が多め

2. サーバー管理基盤としてのPowerShell◦マイルストーンが見えないので正直予測しにくい…

◦ただし、コマンドレットのクロスプラットフォーム対応は確実に増える

◦DSC for Linuxの進化は期待できそう(PowerShell以外にOMIの進化も必要だが…)

26

3. 誰のためのPowerShell

27

28

ここから若干ポエム要素入ります

PowerShell for everyone?

PowerShellは万人向けなのか?

◦PowerShellはサーバー管理、自動化に特化したツール

◦当初はシステム管理者向けのツールとして提供されており、根本的な思想は今も変わっていない※もちろんシステム管理者でない開発者やパワーユーザーの使用も想定されており、

利用するにあたっての敷居は低い

29

PowerShell for everyone?

◦得意領域(一例)サーバー管理◦ 豊富なコマンドレット

定型処理の自動化◦ スクリプト言語としての機能自体は多い

◦不得意領域(一例)複雑なテキストデータの加工◦ grep、awkはかろうじて代替できるが

sedの代替が無い

バイナリデータの加工◦ PowerShellはオブジェクト⇔テキストの変換が基本となっている

大量データを扱う処理◦ PowerShellは基本シングルプロセスで動作するのでメモリ的に死ぬ

30

PowerShellは得意領域と不得意領域が明確に分かれている

誰のためのPowerShell

私見◦PowerShellは利用のための敷居は低いが万人向けのツールではない

◦クロスプラットフォーム化したことにより、より多くの人がPowerShellに触れることになるが無理をしてまで使うものではない

◦とりあえず試して用途に合えば使い続けるくらいのスタンスを取ると良い

31

(補足)PowerShell と Bash

32

Bash on Ubuntu on Windows◦現状Windows10のみ、開発者モード必須

◦サーバーOSに載るかは不明

PowerShellはBash(*sh)ではない◦ Bash(*sh)はドキュメント指向

◦ PowerShellはAPI指向

PowerShellとBashは対立するものではなく、使い分けるもの

(補足)PowerShell とコマンドプロンプト

33

Windows 10 Insider Preview Build 14971でPowerShellが既定のシェルになった件

◦ UI(Explorer)の変更だけでコマンドプロンプトは無くならない

参考資料 Windows PowerShell - Wikipedia

◦ https://en.wikipedia.org/wiki/PowerShell

PowerShell 3.0概要◦ http://winscript.jp/powershell/246

PowerShell 4.0 の機能についてまとめてみる (前、後編)◦ http://tech.guitarrapc.com/entry/2013/10/22/082655

◦ http://tech.guitarrapc.com/entry/2013/10/25/071306

PowerShell v5の新機能と、実戦で使ってほしい機能◦ http://www.buildinsider.net/enterprise/powershelldsc/03

WMF 5.1の新機能をざっくり説明するその1~その4◦ http://stknohg.hatenablog.jp/entry/2016/07/30/191456

◦ http://stknohg.hatenablog.jp/entry/2016/07/30/223710

◦ http://stknohg.hatenablog.jp/entry/2016/07/31/014348

◦ http://stknohg.hatenablog.jp/entry/2016/07/31/185311

34

35