IT Pro のためのスクリプト講座
Windows PowerShell を使おう!
~ 基礎からサーバー管理の自動化まで
2012.3.24 版
日本マイクロソフト株式会社
エバンジェリスト
安納 順一 Junichi Anno
http://blogs.technet.com/junichia/
Facebook: junichi anno
1
開発者 vs インフラ担当者
Development Integration Deployment Delivery
Developer your
machine!
your code! Operator
新しい機能の開発 サービスの展開と
既存機能との統合や 継続的で安定した
改善 サービスの提供
直してほしかったら バグがあるから直してくれ!
詳しい情報をよこせ!
情報が欲しかったら
監視もできねーのかよww 監視方法を詳しく教えろ!
マシンスペックとか知らねーし アプリが重過ぎ!常識で考えろ!
4
DevOps(=Development and Operations)
開発サイドと運用サイドの協調により、
Development ~ Delivery 全体のアジリティを高めるためのプロセス
Developer Operator
ビジネスに合わせた ビジネスに合わせた
アプリケーションの DevOps インフラの進化
進化
協調文化を確立し
”IT”によりビジネスを進化させ
(参考)
る
・Velocity 2009 : “10+ Deploys Per Day: Dev and Ops Cooperation at Flickr” by John Allspaw
・DevOps って何? by 宮下 さん http://www.slideshare.net/mizzy/devops-4156440 5
マイクロソフトの DevOps シナリオ
• Visual Studio 2011
• IntelliTrace Agent
• System Center 2012
• ConfigMgr 構成パック
• OpsMgr 管理パック
• OpsMgr AVICode
開発担当 • Orchestrator(Opalis) 運用担当
• SM インシデント管理
• VMM Portal など
• Windows PowerShell
• SQL Server bacpac
・
・
6
マイクロソフト製品と PowerShell の関係
• 製品ごとに専用の”コマンドレット”が用意されている
• 多くの管理 GUI は裏でコマンドレットを呼んでいる
• インフラ担当者に、各製品への”標準化されたアクセス方法”を提供す
る
Active Directory PowerShell System Center
管理センター コンソール Virtual Machine Manager
Active Directory VMM
PowerShell コマンドレット PowerShell コマンドレット
Active Directory Hyper-V
9
PowerShell が Management Hub となる
IT Solution Service
IT Pro Developer Developer Provider
開
発
Windows Management Framework
標準化されたアクセス Windows PowerShell
他のプラッ
標準化されたプロトコル WS-Man(Web Service for Management)
トフォーム
標準化されたモデル CIMOM、SMI-S NanoWBEM
Pegasus
Disk Storage Exchange Devices YOUR ELEMENTS
10
スクリプトの実行環境
bat VBScript JScript PowerShell スクリプト
PowerShell エンジン
COM
exe
Script Engine C .NET Framework
Windows Script Host O Class Library
cmd/
Cscript.exe Wscript.exe M CLR(共通言語ランタイム)
command
Windows
12
コマンドシェルの進化と機能の包含
DOS/ Win9x/ XP/2003 Win7/ 8
Win31 Me NT 2000 Vista/2008 2008R2
低機能
command.com
cmd.exe
Windows Script Host
Windows PowerShell
100
PowerShell 上では
高機能 bat/vbs/js も実行可能 コマンドレットの数
200
2300
13
引数を受け取る 5つの引数
C:> .hogehoge.ps1 My name is “Junichi Anno” .
Write-Output $args[3] Junichi Anno
foreach ( $a in $args )
My
{ name
Write-Output $a is
Junichi Anno
} .
34