SlideShare a Scribd company logo
INF-009
東屋 善昭
日本マイクロソフト株式会社
エンタープライズパートナー営業統括本部
クラウド&アーキテクチャ技術本部
クラウドソリューションアーキテクト
はじめに
Microsoft Azure のみならず、
PowerShell 関連技術の進歩も速いです
実際の 検証、設計、実装 の際は、
本資料だけでなく、マイクロソフトが
提供している Web サイトなどで、
最新状況を ご確認頂けましたら幸いです
2
本セッション の ゴール
マイクロソフト製品や、Microsoft Azure では、PowerShell は必須スキルですが、
今後登場する Azure Stack、Nano Server、各種コンテナ技術 では、
ますます PowerShell が使いこなせないと、利用する事が困難になります
本セッションでは、現状の PowerShell 中心に関連技術をご紹介し、
自動化対応 エンジニアを目指される為の参考情報をご提供致します
習得に向けての足掛かりになれれば幸いです
3
本日の内容
• 温故知新:マイクロソフト技術 の 方向性 (一部)
• 使いこなせる様になると、こんな事もできる様になる
• 昨年 の de:code にて要素技術の位置づけを紹介
• PowerShell 5.0
• WMF に内包? WMF とは?
• モジュール&スクリプトの追加で使用範囲が広がる
• PowerShell スクリプト 開発ツールは?
• PowerShell スクリプト 稼働場所
• PowerShell が扱えるエンジニアとは? 4
5
信頼性・安定性の高いシステム環境
生産性・拡張性の高い開発環境
社員ひとりひとりの生産性向上
初期投資とその後の運用・管理コストの圧縮
これから、何が必要か?
最適な予算と最適な人員で、
最適な技術を導入・活用した
競争力のある戦略的なシステムを実現すること
2003年開催 の Microsoft Conference
6
Windows Server 2003 からはじまる、
データセンター管理の自動化を実現するための、
3-5年を要する中長期のロードマップ
 XMLをベースとした
自動管理ソリューション
 広範な業界サポートによる、
最高の経済性の実現
 自己管理可能な
アプリケーションの開発を
可能に
 リソースの仮想化と動的な
割り当て
2003年開催 の Microsoft Conference
7
階層化システムモデルのイメージ
アプリケーション
アプリケーション
ホストサービス
ネットワーク & OS
ハードウェア
ソフトウェア ファクトリーのシナリオにもつながる
2005年~2008年 の DSI
8
Merc. Stage ShuttleJob
Cache
HTTP
SQL Feed
Store DSS
FTP
DSI コンセプト
必要なリソース
運用ポリシー運用特性
既存、あるいは
新しいシステム
のモデルを作成
モデルに則した
システム運用
モデルに則した自動的なリソース
確保とシステム構成
ストレージサーバー ネットワークIT ライフサイクルをつなぐ
モデル
2005年~2008年 の DSI
9
Azure 登場 & 進化
10
Microsoft Azure と Windows Azure Pack の 比較
SystemCenter2012R2とServiceProviderFoundation
その他の
サービス
Service
Bus
SQL
仮想
マシン
Web
サイト
サービス
プラン
ユーザー 管理者
ポータル
テナント
セルフサービ
スポータル
Web サイト
アプリ
データ
ベース
仮想マシン
サービスプロバイダーカスタマー
セルフサービス
ポータル
共通の管理
エクスペリエンス
ワークロードの
ポータビリティ
クラウドで利用
できるサービス
一貫性のある開発
エクスペリエンス
その他
のサー
ビス
CDN.
Media,, etc.
Caching
Service
Bus
SQL
VM
ロール
Web
サイト
Worker
ロール
Web サイト
アプリ
データ
ベース
仮想マシン
利用者のセルフ
サービスポータル
Microsoft Azure
Microsoft
Azure の機能を
パッケージ化、
アドオン構築
できる。
WAP 無し
でも稼働OK
11
** - TP1 には Web Apps のみ含まれます、* - TP1 には含まれません
2015年5月 の イベント Ignite にて発表
12
見た目も 運転方法も 同じ車ですが。。
例え話:アーキテクチャーの進化
ガソリンエンジンを整備していた エンジニア は、テスラを整備する為には、
新たに勉強しないと 整備する事は出来ない
TCO 削減 & 新技術提供を 目的とした Azure は、プラットフォームが進化している
オンプレ で培ってきた スケールアップ システム アーキテクチャー に追加して、
クラウド技術 の スケールアウト システム アーキテクチャー を 新たに勉強する必要がある
13
さらに進化。。
The Azure Application Platform
14
Build on Dev frameworksBuild on Infrastructure
Preview
GA
“App Creators”
Developers Analysts
Microsoft Azure
LOBSaaSLift & Shift Docker
Virtual
Machines
Stateful and
stateless one-
off solutions
VM
ScaleSets
Scalable
solutions
Container
Service
Scalable,
orchestrated
Docker images
deployed into
containers
Differentiation Time to valueExisting App Investments
Batch
Custom High
Performance
Computing
solutions
Open
Source
PaaS
Cloud
Foundry,
Open Shift
Service
Fabric
Custom
Microservice-
based
stateless and
stateful
solutions
Power
Apps
Graphical
design
mobile
solutions
App Service
Template based
rapid
development
web, mobile and
API solutions
Orchestrated
workflow
based
integration
solutions
LogicWeb/Mob/
API
All the
goodness of
App Service
in a
dedicated
environment
Environments
2016年3月 の イベント Build にて発表
15
• 提供されるソリューション (2015年5月 時点)
• Remote monitoring:リモート監視
• Predictive maintenance:予測的なメンテナンス
Azure IoT Suite
16
Azure IoT Suite components
(Remote monitoring:リモート監視)
17
Azure IoT Suite
18
ソースは、GitHub から公開
Azure IoT Suite の構成済みソリューション ドキュメント
https://azure.microsoft.com/ja-jp/documentation/articles/iot-suite-what-are-preconfigured-
solutions/
Remote monitoring:リモート監視
https://github.com/Azure/azure-iot-remote-monitoring
Predictive maintenance:予測的なメンテナンス
https://github.com/Azure/azure-iot-predictive-maintenance
19
20
昨年 の de:code 2015 セッション
https://channel9.msdn.com/Events/de-code/decode-2015/MOP-005
21
22
コマンドシェルの進化と機能の包含
23
cmd.exe
command.com
高機能
NT
低機能
DOS/
Win31 2000
XP/2003
Vista/2008
Windows Script Host
PowerShell 上では
bat / vbs / js も実行可能
Win9x/
Me
Win7/
2008R2
Windows PowerShell
100
200
約 3000 超
コマンドレットの数
Win8/
2012/R2
PowerShell 5.0
24
2012年9月リリース
動作環境: .NET Framework 4.0 ~
対応OS
Windows Server 2012 (標準搭載)
Windows Server 2008 SP2 & R2 SP1
Windows 8 (標準搭載)
Windows 7 SP1
搭載機能
PowerShell Workflow
PowerShell Web Access
CIM integration
Scheduled Jobs Integration
Task Scheduler Integration
Core Cmdlets 多数追加
各サーバー製品毎の Cmdlets 多数追加
他多数
2013年10月リリース
動作環境: .NET Framework 4.5 ~
対応OS
Windows Server 2012 R2 (標準搭載)
Windows Server 2012
Windows Server 2008 R2 SP1
Windows 8.1 (標準搭載)
Windows 7 SP1
搭載機能
PowerShell Desired State Configuration (DSC)
PowerShell Web Services
PowerShell Web Access 機能強化
PowerShell Workflow 機能強化
PowerShell ISE 機能強化
Core Cmdlets 機能強化/多数追加
各サーバー製品毎の Cmdlets 多数追加
他多数
2015年12月リリース
動作環境: .NET Framework 4.5 ~
対応OS
Windows Server 2016 (標準搭載)
Windows Server 2012 & R2
Windows Server 2008 R2 SP1
Windows 10 (標準搭載)
Windows 8.1
Windows 7 SP1
搭載機能
PackageManagement (旧称 OneGet)
PowerShell DSC 機能強化
PowerShell Web Services Odata 対応
PowerShell ISE 機能強化
セキュリティ機能強化 (JEA Admin)
Core Cmdlets 機能強化/多数追加
各サーバー製品毎の Cmdlets 多数追加
他多数
2009年10月リリース
動作環境: .NET Framework 2.0 ~
対応OS
Windows Server 2008 R2 (標準搭載)
Windows Server 2008 SP1
Windows Server 2003 SP2 & R2 SP2
Windows 7 (標準搭載)
Windows Vista SP1
Windows XP SP3
搭載機能 (一部)
Remoting
Background Jobs
PowerShell ISE
GridView
スクリプト言語 機能強化
セキュリティ機能強化
Core Cmdlets 多数追加
各サーバー製品毎の Cmdlets 多数追加
他多数
2006年11月リリース
動作環境: .NET Framework 2.0
対応OS
Windows Server 2003 SP1 & R2 SP1
Windows Vista
Windows XP SP2
搭載機能 (一部)
Core Cmdlets 多数登場
PowerShell Provider
Script Language
2016年11月14日
PowerShell 10周年 になります
25
WMFとは? (1/3)
26
Technology
Partner
Storage Network DevicesDisk Other ELEMENTS
IT Pro IT Developer
Solution
Developer
Windows Management
Instrumentation
(WMI)
CIM, WBEM
CIM, WBEM CIM, WBEM CIM, WBEMCIM, WBEM CIM, WBEM
WMFとは? (2/3)
27
Windows Management Framework
(WMF)
Technology
Partner
Storage Network DevicesDisk Other ELEMENTS
IT Pro IT Developer
Solution
Developer
Windows Management
Instrumentation
(WMI)
CIM CIM CIMCIM CIM
CIM, WBEMCIM, WBEM CIM, WBEM CIM, WBEMCIM, WBEM CIM, WBEM
WMFとは? (3/3)
28
Technology
Partner
PowerShell CIM Client OData
CIM Schema WMI
Storage Network DevicesDisk Other ELEMENTS
IT Pro IT Developer
Solution
Developer
Windows Management
Instrumentation
(WMI)
Standardized Protocols
WS-Management (WS-Man)
(WinRM:サーバー側 Windows Remote Management、WinRS: クライアント側 Windows Remote Shell)
REST HTTP PSRP (PowerShell Remoting)
CIM CIM CIMCIM CIM
CIM, WBEMCIM, WBEM CIM, WBEM CIM, WBEMCIM, WBEM CIM, WBEM
Windows Management Framework
(WMF)
PowerShell ISE
PowerShell DSC
PowerShell Web Services
Just Enough Administration
PackageManagement (a.k.a. OneGet)
PowerShellGet
PowerShell Script Debugging
Network Switch Management
Audit PowerShell Usage using
Transcription and Logging
Software Inventory Logging
etc
• WMI: Windows Management Infrastructure
• Windows の多くのシステム情報にアクセス可能
• 設定の変更も可能
• WinRM / WinRS(WS-Management)
• サーバー側: WinRM (Windows Remote Management)
• クライアント側: WinRS (Windows Remote Shell)
• システム管理のための Web サービス
• HTTP, HTTPS でリモートマシンにコマンド発行が可能
• リモートの WMI にアクセス
ローカル、リモート 管理
29
PowerShell
WMI WS-Management WMI
WS-Management
ローカル リモート
PowerShell 5.0 & WMF 5.0 新機能 (1/2)
30
PowerShell Web Services Odata 対応
PowerShell ISE 機能強化
セキュリティ機能強化 (JEA Admin)
PowerShell クラス定義 (プロパティ、メソッド)
PowerShell .NET 列挙型
コミュニティからの要望があった コマンドレット の新規追加&機能強化
ODataUtils と OData エンドポイント の コマンドレット を追加
ZIP アーカイブ の コマンドレット を追加
シンボリック リンク操作 の コマンドレット を機能強化
Network スイッチ の コマンドレット を追加
PowerShell ISE で DSC の作成機能の強化
DSC の コンフィグレーション キーワード に 32-ビット をサポート
PowerShell の使用状況をロギングする監査機能強化
テキストデータを構造化オブジェクトへ変換
DSC LCM (Local Configuration Manager) バージョン 2.0
DSC の LCM (Local Configuration Manager) に メタ構成属性 も構成可能
DSC の コンフィグレーション内を部分的に分割定義可能
DSC でコンピューター間の依存関係を管理可能
DSC の構成をより細かく制御可能
DSC の構成状態についての詳細把握可能
DSC のデバッグ機能強化
DSC RunAsCredential のサポート
DSC LCM の情報追加
DSC リソース のサイド バイ サイド インストール
DSC からの構成ステータス レポートを集中収集可能
PSDesiredStateConfiguration モジュールを 1.1 にバージョンアップ
PackageManagement (旧称 OneGet) で、ソフトウェアを検索&インストール
PowerShellGet モジュール で、PowerShell Gallery を 検索&ダウンロード&インストール&可能
PowerShell で、クラスの開発可能
PowerShell 実行空間リモート プロセスのデバッグ
PowerShell のバック グラウンド ジョブのデバッグ
ソフトウェア インベントリ の ログ収集可能
CMS (Cryptographic Message Syntax) にて、RFC5652 準拠の 暗号化/複合化を追加
16進数 (Hex) 対応フォーマット追加
テンポラリーファイル 作成可能
クリップボード の操作可能
GUID 生成可能
ゴミ箱 操作可能
レジストリ値 を直接取得可能
Job や Workflow にて、ストリーム情報が追加
テキスト文章作成時の改行追加不可
フォルダ検索時の階層段階制御
ローカル と リモート間でのファイル コピー機能
Nano Server 対応
PowerShell 5.0 & WMF 5.0 新機能 (2/2)
New features in Windows PowerShell 5.0
https://technet.microsoft.com/en-us/library/hh857339.aspx#BKMK_new50
Windows Management Framework 5.0 Production Preview is now available
https://blogs.msdn.microsoft.com/powershell/2015/08/31/windows-management-
framework-5-0-production-preview-is-now-available/
Windows Management Framework (WMF) 5.0 RTM is now available
https://blogs.msdn.microsoft.com/powershell/2015/12/16/windows-management-
framework-wmf-5-0-rtm-is-now-available/
Windows Management Framework (WMF) 5.0 currently removed from Download Center
https://blogs.msdn.microsoft.com/powershell/2015/12/23/windows-management-
framework-wmf-5-0-currently-removed-from-download-center/
Windows Management Framework 5.0 ダウンロードセンター
https://www.microsoft.com/en-us/download/details.aspx?id=50395
31
PackageManagement Architecture (旧OneGet)
32
End User
PackageManagement
PowerShell cmdlets
PackageManagement
Core
Discovery
Install/Uninstall
Inventory
PackageManagement
Providers
Windows Server App (WSA)
PowerShellGet
Windows Container
NuGet
NanoServerPackage
…
Package Sources
WSA Package Repository…
PowerShell Gallery
Container Gallery, Docker
NuGet Gallery …
www.NPMjs.com
WordPress, …
Documentation
https://technet.microsoft.com/en-us/library/mt422622.aspx
PackageManagement and NuGet provider source are in GitHub
http://oneget.org
ホームページ、ギャラリーが一新しました
33http://www.microsoft.com/powershell http://www.powershellgallery.com
34
• PowerShell の実行単位は、コマンドレット
• モジュールは、製品単位や、機能単位に、コマンドレット&他 をパックにした物
• モジュール内に格納されている コマンドレット一覧を見る時:Get-Command -Module PowerShellGet
• モジュールがインポートされていないとコマンドレットは使用できない
• 機能を使用したい場合、モジュールを ダウンロード → インストール → インポート する
• PowerShell 5.0 からの PowerShellGet モジュール 内の Install-Module にて、PowerShell
Gallery から、ダウンロード&インストールが可能になった
• インストール後に、Import-Module コマンドレット にてインポート
• バッチファイル の様に、行単位にコマンドレットを記述し、行単位に実行される
• 一般的なスクリプト言語と同じく、変数、繰返し文、条件文制御構文、配列、エラー処理などを
使用して高度な処理を行う事も可能
モジュール&スクリプトを追加すると使用範囲が広がる
(1/3)
35
モジュール自体の開発を行いたい時:Writing a Windows PowerShell Module
https://msdn.microsoft.com/en-us/library/dd878310.aspx
モジュール&スクリプトを追加すると使用範囲が広がる
(2/3)
モジュール の メジャーバージョンは、
Web PI (Web Platform Installer) から、ダウンロード&インストール
https://www.microsoft.com/web/downloads/platform.aspx
36
モジュール&スクリプトを追加すると使用範囲が広がる
(3/3)Microsoft から提供する 各製品&サービス の PowerShell 関連 の
モジュール&スクリプトは、PowerShell Gallery に 掲載されていきます
Microsoft 社外の方々が作成された モジュール&スクリプト を
アップロード&公開 も可能
https://www.powershellgallery.com/ 37
38
• Windows PowerShell 専用エディタ
• スクリプトおよびモジュールを記述, 実行, テストができるホスト アプリケーション
• 構文の色指定, タブ補完, 視覚的なデバッグ機能, ユニコード準拠, 状況依存のヘルプなどの
主要な機能により、多彩なスクリプトの操作性を提供
• 対話型のコマンドを実行できるコマンドペイン
• コマンドの出力をキャプチャする出力ペイン
• 関数, スクリプト, モジュールを作成, 編集,
デバッグ, 実行するためのスクリプト ペイン
• 複数の独立タスクを同時実行できる
PowerShell タブ (Ctrl + T)
• Powershell_ise.exe は、Windows 7 以降搭載
• IntelliSense, Snippets に対応
PowerShell スクリプト 開発ツール(1)
Windows PowerShell ISE (Integrated Scripting Environment)
39
PowerShell スクリプト 開発ツール(2)
Visual Studio Code
40
Visual Studio Code は、
Windows, Linux, OS X のお好きな
プラットフォームで無料で利用可能
Visual Studio Codeは、
30 以上の言語に対応サポート
https://www.visualstudio.com/products/code-vs https://marketplace.visualstudio.com/VSCode
PowerShell
Language Support
for
Visual Studio Code
41
PowerShell スクリプト 開発ツール(2)
Visual Studio Code
Announcing PowerShell language support for Visual Studio Code and more!
https://blogs.msdn.microsoft.com/powershell/2015/11/16/announcing-powershell-
language-support-for-visual-studio-code-and-more/
Visual Studio Code ホームページ
https://www.visualstudio.com/products/code-vs
Visual Studio Code Marketplace
https://marketplace.visualstudio.com/VSCode
Visual Studio Code 取扱説明書
https://code.visualstudio.com/docs
Debugging (launch.json 解説)
https://code.visualstudio.com/docs/editor/debugging 42
PowerShell スクリプト 開発ツール(3)
Visual Studio (Enterprise / Professional / community)
43
[ツール]-[拡張機能と更新プログラム] から、
オンライン での、[PowerShell] で検索して、
PowerShell Tools for Visual Studio 2015
をインストール
PowerShell Tools for Visual Studio 2015
https://visualstudiogallery.msdn.microsoft.com/ (PowerShellで検索)
PowerShell Tools for
Visual Studio 2015
44
PowerShell スクリプト 開発ツール(3)
Visual Studio (Enterprise / Professional / community)
45
Visual Studio の 各エディション の PowerShell Tools for Visual Studio 2015 対応表
エディション 無料/有料
PowerShell Tools for
Visual Studio 使用可否
備 考
Visual Studio Enterprise 2015 有料 使用可能
Visual Studio Professional 2015 有料 使用可能
Visual Studio Community 2015 無料 使用可能
●個人用
個人開発者の方はどなたでも、独自の無料/有料のアプリを作成するために Visual Studio Community を使
用できます。
●組織用
組織が学習環境のクラスルームで、アカデミックな研究のため、あるいはオープン ソース プロジェクトに寄
与するために、Visual Studio Community を使用する場合には、ユーザー数に制限はありません。
●それ以外の使用シナリオ
エンタープライズ以外の組織では最大 5 ユーザーで Visual Studio Community を使用できます。
エンタープライズ組織 (>PC 250 台>または年間売上が 100 万米ドルの組織) については、オープン ソース、
アカデミックな研究、学習環境のクラスルームといった前述のシナリオ以外で使用することはできません。
Visual Studio Express 2015 for Desktop 無料 使用不可
●Express 製品の商業目的の使用
Visual Studio Express 製品は、各製品のライセンス条項に従うことを条件として、無料で商用、製造用に使
用できます。 たとえば、Express for Windows を使用してアプリを作成し、Windows ストアで販売するこ
とができます。
Visual Studio Express 2015 for Web 無料 使用不可
Visual Studio Express 2015 for Windows 10 無料 使用不可
Visual Studio ダウンロード
https://www.visualstudio.com/downloads/download-visual-studio-vs
Visual Studio Community 2015 ライセンス条項
https://www.visualstudio.com/support/legal/mt171547
Visual Studio Express 2015 ライセンス条項
https://www.visualstudio.com/support/legal/mt171551
PowerShell スクリプト 開発ツール(3)
Visual Studio (Enterprise / Professional / community)
46
Visual Studio 2015 製品の比較
https://www.visualstudio.com/products/
compare-visual-studio-2015-products-vs
47
PowerShell スクリプト稼働場所
48
Microsoft Azure Azure Stack オンプレミス
IaaS
ゲスト OS (ノード)
内部構成
LCM:PowerShell DSC Local Configuration Manager
IaaS
ゲスト OS (ノード)
内部構成
ゲスト OS (ノード)
内部構成
PowerShell DSC
Azure Automation
49
PowerShell DSC の 構成機能
伝統的なスクリプト
特定の技術
DSC Engine
依存関係の解決
ログ&エラー処理
再起動にも対応
反復処理も可能
Resources
実行される処理
Configuration
Intent (目的)
50
PowerShell スクリプト と PowerShell DSC との違い
 PowerShell スクリプト
Import-Module ServerManager
# IIS (Web Server) IIS がインストールされているか否かを確認して、
未インストールであれば、IIS をインストールする
$feature = Get-WindowsFeature -Name Web-Server
if(($Ensure -eq "Present") -and (!$feature.Installed))
{
Install-WindowsFeature -Name Web-Server
}
 PowerShell DSC
Configuration Install-IIS
{
Node localhost
{
WindowsFeature IIS
{
Ensure = "Present"
Name = “Web-Server"
}
}
}
例:IIS の 追加インストール
PowerShell スクリプト では、手順を全てコーディングする必要があるので、
インストールされているか否か の 条件も考慮して コーディングする必要がある
PowerShell DSC では、望まれた結果(結果の状態) を パラメータ として記述する
Ensure = “Present” で、状態の結果は、IIS がインストール済みを表す
DSC では、状態の結果を 宣言的に構文を記載するので、条件文は存在しない
※リソースを開発する際には、Configuration 側では条件文を書かない事を考慮する必要がある
(何度実行してもエラーにならない ロジックを リソース内に開発する必要がある)
Configuration と記述して、
DSC の 宣言的構文 を 記述
Install-WindowsFeature は、
Windows Server の機能追加を行う コマンドレット
WindowsFeature は、
PowerShell DSC の
標準リソースで、
Windows の追加機能名を
パラメータとして記載
51
• PowerShell DSC の リソース自体は、PowerShell スクリプト
なので、個別に独自開発する事が可能
• DSC Resource Kit (All Modules:Wave10) 2015/8/8 Update
• https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d
• 48モジュール
• DSC Resource Kit Update 2016/4/4
• https://blogs.msdn.microsoft.com/powershell/2016/04/04/dsc-resource-kit-update/
• 48の内、21モジュールをアップデート、6モジュール追加、Total 279 リソース
• ダウンロードは、PowerShell Gallery から行う
PowerShell DSC の リソース
52
Push型 と Pull型
Push 型
管理サーバーから
設定情報を送る
Pull 型
定期的に
管理サーバーに問い合わせ
望まれた状態に、自動的に構成し続ける事が可能一時的or継続的に管理サーバの トリガー
(人的 orスケジュール) により、自動構成する
Push and Pull Configuration Modes
http://blogs.msdn.com/b/powershell/archive/2013/11/26/push-and-pull-configuration-modes.aspx 53
自動構成ツール の 使い処
●Microsoft Azure / Stack
Azure Resource Manager
Azure Automation
●オンプレミス
System Center Orchestrator
仮想マシンの外側か内側かで
自動化の目的が異なる
PowerShell DSC Chef Puppet
54
PowerShell DSC の Pull サーバー
Configuration
(script)
DSC
Resources
コード作成/編集
MOF
MOF
Node
Configuration
(MOF)
Zip
Zip
Zip
ステージング
コンパイル
Zip
Azure
仮想マシン
物理
サーバー
オンプレミス
仮想サーバー
MOF
MOF
Node
Configuration
(MOF)
Zip
Zip
Zip
Rest Endpoint
レポート
データ
55
Azure Automation DSC (Pull のみ , Push なし)
Configuration
(script)
DSC
Resources
MOF
MOF
Node
Configuration
(MOF)
Zip
Zip
Zip
レポート
Azure
仮想マシン
物理
サーバー
オンプレミス
仮想サーバー
Rest Endpoint
コード作成/編集
ステージング
Azure
Automation
56
Azure Automation
自動処理タスク
Runbook
(PowerShell)
タスクを
オンデマンド配信
処理状況監視
ログ管理
Azure の各機能や、サードパーティーから
提供されている PowerShell を利用可能
運用コスト削減する柔軟なプロセス ワーク
フロー
PowerShell DSC 対応
インターネットからの実行可能
Azure から オンプレミスへ 実行可能
プロセス最適化
&拡張
管理ポータルに テキスト/グラフィカル の
エディターを用意
ライブラリより、コマンドレッドや
Runbook、アセット を一覧できるライブラ
リを用意
管理ポータルより
作成&編集が可能
オペミス削減によるコスト削減&システム
信頼性向上
スケーラブルな高可用性の要求を満たす実
行環境を提供
起動方法:スケジュール機能、Webhooks、
PowerShell (Start-AzureAutomationRunbook)
運用作業におけるコ
スト削減
統合 編集 Automation
Azure
Automation
編集
実行統合
57
Azure Automation の ギャラリ参照(1/3)
58
https://gallery.technet.microsoft.com/
Azure Automation の ギャラリ参照(2/3)
59
Azure 管理 ポータル
Azure Automation の ギャラリ参照(3/3)
60
Azure 管理ポータル (クラシック )
61
• PowerShell は開発言語です
• コマンドレットだけを並べても、自動化処理は行えません
• 実際の業務では、自分が毎回新規コーディングする事はなく、他人がコーディン
グしたソースを読んで、潜んでいるバグを発見&修正するスキルが必要
• サンプル ソース の 読解力も必要
• 手作業の最中に、頭で判断、単純繰り返し作業など を人的に行っていた事を
PowerShell スクリプト へ、書き替える開発も多いです
• PowerShell は、開発言語なので。。。
パラメーター , 変数 , 文字列 , 型 , 配列 , 演算式 , 条件文 , 繰返し処理 ,
関数 , パイプライン , リダイレクト , ワイルドカード , エラー処理 , などなど
基礎中の基礎を知っておかないと、読み 書き は、できません
PowerShell が扱えるエンジニアとは?
62
『ARMではじめるMicrosoft Azureの新規構築・運用管理の自動化』
コース提供が、始まります!!
• Azure PowerShell や Azure Resource Manager テンプレートを使った
デプロイや運用管理の基礎を学べる入門コースです
• プログラム初学者、苦手な方に向けて PowerShell・JSON の基本構文から
トラブルシューティングまでわかりやすくご紹介します!
• 前編/後編 の e-Learning +手元 で動作確認するための手順書で
実践しながら学習できます
詳細は http://www.knowledgewing.com/arm/ から
開発&提供:2016年6月 1日:お申込み受付開始予定
2016年6月27日:開講予定
64
参考情報
PowerShell 学習教材
65
• Windows PowerShell でのスクリプティング
https://technet.microsoft.com/ja-jp/scriptcenter/dd742419.aspx
• Azure Cmdlet Reference
https://msdn.microsoft.com/en-us/library/azure/jj554330.aspx
最新情報は、 Get-Help コマンドレット
例:Get-Help Import-Module -Full
PowerShell 技術情報 (1/2)
66
PowerShell Blog
PowerShell の最新情報はココから
https://blogs.msdn.microsoft.com/powershell/
PowerShell on User Voice
PowerShell 開発チームへ直接リクエストできます
https://windowsserver.uservoice.com/forums/301869-powershell
同じ要望があれば、投票ボタンを押します
カウント数が多い事案から、開発チームが検討します
PowerShell 技術情報 (2/2)
67
PowerShell 開発チーム の GitHub
https://github.com/powershell
PowerShell DSC 技術情報
68
日本語:https://msdn.microsoft.com/ja-jp/powershell/dsc/overview
英語:https://msdn.microsoft.com/en-us/powershell/dsc/overview
• Linux 用 PowerShell DSC 使用方法
• https://msdn.microsoft.com/ja-jp/powershell/dsc/lnxgettingstarted
• 以下の Linux をサポート
• CentOS 5、6、および 7 (x86/x64)
• Debian GNU/Linux 6 および 7 (x86/x64)
• Oracle Linux 5、6 および 7 (x86/x64)
• Red Hat Enterprise Linux Server 5、6 および 7 (x86/x64)
• SUSE Linux Enterprise Server 10、11、および 12 (x86/x64)
• Ubuntu Server 12.04 LTS および 14.04 LTS (x86/x64)
• DSC サーバー側
• Open Management Infrastructure (OMI) CIM サーバーのバージョン 1.0.8.1 が必要
• https://collaboration.opengroup.org/omi/ からダウンロード
• ゲスト OS (ノード)側
• PowerShell Desired State Configuration for Linux をインストール
https://github.com/Microsoft/PowerShell-DSC-for-Linux/releases/tag/v1.1.1-70
Linux 用 PowerShell Desired State Configuration (DSC)
69
お互い Windows も Linux の両方が対象なので、
どちらを選択したら良いか?
• 既存資産 or 今後の環境 で、Windows と Linux の保有台数で選択
• 既にどちらかを使用しているのであれば、慣れている方を選択
• DSC 以外の自動化機能も利用するなら、その比率も考慮して選択
PowerShell DSC と Chef / Puppet の選択 (案)
70
Azure Automation 技術資料
71
https://azure.microsoft.com/ja-jp/documentation/services/automation/
この階層内に
詳細技術資料が
数多く収集され
ています
Azure Automation ラーニング パス
72
https://azure.microsoft.com/ja-jp/documentation/learning-paths/automation/
73
ま と め
ま と め
PowerShell が 読み 書き 出来る様になるだけで、
仕事の幅がイッキに広がります
システム設計&運用設計、構築&テスト作業&運用作業 など
の手法なども進化し、無くなる既存作業、これまで無かった
新しい作業も現れます
システム設計、運用設計、構築&テスト作業、
運用作業などの工数を激減させる事も可能です
楽になった分、新しいクラウド技術を勉強する
時間に割り当てましょう (^O^)/ 74
75
76
追加情報
• PowerShell 自体 のバージョン
• PowerShell ISE などから $PSVersionTable を実行
• Azure PowerShell の バージョン
• PowerShell ISE などから Get-Module -ListAvailable を実行
• 最新のバージョンは いくつ?
https://github.com/Azure/azure-powershell/releases
• 最新バージョンのインストールは、Web PI から実行
お手元のPC内の バージョン確認方法は?
77
• どの様なDSC Resource がある?
• Get-DscResource
• 見つけたDSC Resource の プロパティ構成は?
• Get-DscResource -Name WindowsFeature | Select-Object -ExpandProperty
Properties
• Get-DscResource -Name WindowsFeature | % Properties # 省略形
• 見つけたDSC Resource の プロパティ構成は?
• Get-DscResource -Name WindowsFeature –Syntax
または
PowerShell ISE で記述時に、IntelliSense (Ctrl+Space)
DSC Configuration 構文の調べ方
78
• DSC Resource Kit Update 2016/4/4
• https://blogs.msdn.microsoft.com/powershell/2016/04/04/dsc-resource-kit-update/
• 48の内、21モジュールをアップデート、6モジュール追加、Total 279 リソース
• ダウンロードは、PowerShell Gallery から行う
• DSC Resource Kit Anniversary Release 2016/5/18
• https://blogs.msdn.microsoft.com/powershell/2016/05/18/dsc-resource-kit-anniversary-
release/
• 52 モジュールの内、23 モジュールをアップデート、23 モジュール追加、Total 302 リソース
• ダウンロードは、PowerShell Gallery から行う
スライド 52 の アップデート
79
Azure Automation PowerShell ISE add-on
80
• Azure Automation PowerShell ISE アドオンを発表
https://blogs.technet.microsoft.com/jpitpro/2016/01/19/azur
e-automation-powershell-ise/
• Announcing the Azure Automation PowerShell ISE add-on
https://azure.microsoft.com/ja-jp/blog/announcing-azure-
automation-powershell-ise-add-on/
• Introducing Service Management Automation ISE add-on
https://blogs.technet.microsoft.com/orchestrator/2016/04/2
8/introducing-service-management-automation-ise-add-on/
• Azure Automation PowerShell ISE Add-On
https://github.com/azureautomation/azure-automation-ise-
addon
• チェックポイントを活用して、
信頼性の高いフォールト トレラントな Runbook を実行
• https://blogs.msdn.microsoft.com/windowsazurej/2014/09/11/azure-automation-1254/
• ページ内は、30分 と記載されていますが、現在は機能拡張して 3時間 です。
• 3時間 記載は、コチラ。(2016年3月21日 公開)
Azure Automation での Runbook の実行
• https://azure.microsoft.com/ja-jp/documentation/articles/automation-runbook-
execution/#-2
• 実行開始タイミングは、コチラ。(2016年1月 公開)
Automation の SLA
• https://azure.microsoft.com/ja-jp/support/legal/sla/automation/v1_1/
Azure Automation お作法 (フェア シェア)
81
• WMI Architecture
https://msdn.microsoft.com/en-us/library/aa394553(v=vs.85).aspx
• Windows Remote Management Architecture
https://msdn.microsoft.com/en-us/library/aa384464(v=vs.85).aspx
• Windows PowerShell Desired State Configuration の組み込みリソース
https://msdn.microsoft.com/ja-jp/powershell/dsc/builtinresource
参考URL
82
• 1インスタンスにて、Local Host の構成を行う
デモで使用したスクリプト:PowerShell DSC (1/6)
83
# DSC のローカル の構成内容
Configuration ConfigIISInstall
{
Import-DscResource –ModuleName "PSDesiredStateConfiguration"
Node $Node
{
WindowsFeature IIS
{
Name = "Web-Server"
Ensure = "Present"
}
}
}
# MOF ファイル作成
$Node = "localhost"
ConfigIISInstall -OutputPath C:¥Users¥yoshiazu
# Local Host に適用
Start-DscConfiguration -Path C:¥Users¥yoshiazu -Wait -Verbose
• Push / Pull にて、サーバー(ローカル) と 各ノード(リモート)を
WS-Management にて、CIM セッションを確立する
デモで使用したスクリプト:PowerShell DSC (2/6)
84
# Push / Pull ローカル側の作業 リモート側の作業は無し)
# 管理者モードで以下を実行
# ドメイン配下での場合
Enable-PSRemoting
# ドメインが無い場合は、信頼できるホストを指定する (ワイルドカード使用可)
Set-Item wsman:¥localhost¥Client¥TrustedHosts -Value * -Force
# 設定確認
Get-Item -Path "wsman:¥localhost¥Client¥TrustedHosts"
# CIM セッション確立
New-CimSession -ComputerName de16-DSC-Push-C,de16-DSC-Push-D
# 確立されている CIM セッションの確認
Get-CimSession
• Push にて、サーバーから、各ノード の LCM (PowerShell DSC Local Configuration Manager) の設定を行う
デモで使用したスクリプト:PowerShell DSC (3/6)
85
[DSCLocalConfigurationManager ()]
Configuration LCMConfigPush
{
Node $Node {
Settings {
AllowModuleOverwrite = $True
ConfigurationMode = 'ApplyAndAutoCorrect' # ApplyAndMonitor → ApplyAndAutoCorrect
ConfigurationModeFrequencyMins = 30 # 15 → 30
RefreshMode = 'Push'
RebootNodeIfNeeded = $True
}
}
}
# Meta MOF ファイル作成
$Node = 'de16-DSC-Push-C','de16-DSC-Push-D'
LCMConfigPush -OutputPath C:¥Users¥yoshiazu
# 各ノード に適用
Set-DSCLocalConfigurationManager -ComputerName $Node -Path C:¥Users¥yoshiazu –Verbose
# LCM 内の設定情報を確認
Get-DscLocalConfigurationManager -CimSession $Node
• Push サーバーから、各ノードへ構成を行う
デモで使用したスクリプト:PowerShell DSC (4/6)
86
# DSC Pushサーバー の 各ノードへの構成内容
Configuration ConfigIISInstall
{
Node $Node
{
WindowsFeature IIS
{
Name = "Web-Server"
Ensure = "Present"
}
}
}
# MOFファイル作成
$Node = "de16-DSC-Push-C","de16-DSC-Push-D"
ConfigIISInstall -OutputPath C:¥Users¥yoshiazu
# 各ノード に Push適用
Start-DscConfiguration -Path C:¥Users¥yoshiazu -ComputerName $Node -Wait –Verbose
• Pull サーバー構築
デモで使用したスクリプト:PowerShell DSC (5/6)
87
configuration PullServerHttp {
Import-DSCResource -ModuleName xPSDesiredStateConfiguration
Node $Node {
WindowsFeature DSCServiceFeature {
Ensure = "Present"
Name = “DSC-Service” }
WindowsFeature IISConsole {
Ensure = "Present"
Name = “Web-Mgmt-Console” }
xDscWebService PSDSCPullServer {
Ensure = "Present"
EndpointName = "PSDSCPullServer"
Port = 8080
PhysicalPath = "$env:SystemDrive¥inetpub¥wwwroot¥PSDSCPullServer"
CertificateThumbPrint = "AllowUnencryptedTraffic"
ModulePath = "$env:PROGRAMFILES¥WindowsPowerShell¥DscService¥Modules"
ConfigurationPath = "$env:PROGRAMFILES¥WindowsPowerShell¥DscService¥Configuration"
State = "Started"
DependsOn = "[WindowsFeature]DSCServiceFeature"
}
}
}
# MOF ファイル作成
$Node = "localhost"
PullServerHttp -OutputPath C:¥Users¥yoshiazu
# Local Host に適用
Start-DscConfiguration -Path C:¥Users¥yoshiazu
-ComputerName localhost -Verbose -Wait
• Pull にて、サーバーから、各ノード の LCM (PowerShell DSC Local Configuration Manager) の設定を行う
デモで使用したスクリプト:PowerShell DSC (6/6)
88
[DSCLocalConfigurationManager()]
Configuration LCMConfigPull {
param (
[Parameter(Mandatory=$true)]
[string[]]$ComputerName,
[Parameter(Mandatory=$true)]
[string]$guid )
Node $Node {
Settings {
AllowModuleOverwrite = $True
ConfigurationMode = 'ApplyAndAutoCorrect'
RefreshMode = 'Pull'
ConfigurationID = $guid }
ConfigurationRepositoryWeb DSCHTTP {
ServerURL = 'http://de16-dsc-http-s:8080/PSDSCPullServer.svc/'
#CertificateID = 'D0916BFB09B40E7568A74'
AllowUnsecureConnection = $true }
}
}
# Meta MOF ファイル作成
$Node = 'de16-DSC-Http-C'
$guid=[guid]::NewGuid()
LCMConfigPull -ComputerName $Node -Guid $guid -OutputPath
C:¥Users¥yoshiazu
# 各ノード に適用
Set-DSCLocalConfigurationManager -ComputerName $Node -Path
C:¥Users¥yoshiazu –Verbose
# LCM 内の設定情報を確認
Get-DscLocalConfigurationManager -CimSession $Node
89

More Related Content

PPTX
1st step LogicFlow
PDF
Nano Server First Step
PDF
PowerShell 5.0 で広がる運用管理の世界
PDF
Application Platform としての Windows Server 2019
PDF
Windows PowerShell 5.0 と Windows Server vNext の管理
PDF
Windows Azure and PowerShell DSC
PDF
PowerShell 5.0 JEA (Just Enough Administration) First Step
PDF
PowerShell 5.0 & Security
1st step LogicFlow
Nano Server First Step
PowerShell 5.0 で広がる運用管理の世界
Application Platform としての Windows Server 2019
Windows PowerShell 5.0 と Windows Server vNext の管理
Windows Azure and PowerShell DSC
PowerShell 5.0 JEA (Just Enough Administration) First Step
PowerShell 5.0 & Security

What's hot (20)

PDF
Getting started with Windows Containers
PPTX
20180630 data transformationusinglogicflow
PDF
夏サミ2014 クラウドとCIツールで変わるエンタープライズJava開発
PPTX
System Center Operations Manager 2019
PDF
60分でわかる!SilverlightとWPFの入力チェック
PDF
System Center 2012, Endpoint Protectionの運用
PPTX
PowerShell DSC 入門
PDF
App controllerとSPFで実現するハイブリッドクラウド
PDF
WebSphere Application Server V8.5.5 Libertyプロファイルのご紹介 #jjug_ccc #ccc_r51
PPTX
ついに始まるJava EE 7時代のアプリケーション開発
PDF
Eclipse と Liberty プロファイルで始める Java EE 開発ハンズオン #jjug_ccc #ccc_r51
PDF
IBMが新しいJava EEコンテナを作っているらしい -Libertyプロファイルとは-
PDF
17-D-1 Azure開発の極意 ~2011年版~
PDF
GoodBye AD FS - Azure Active Directory Only の認証方式へ切り替えよう!
PDF
Ws2012 directaccessで実現するworkanyshereシナリオ 121208
PDF
Direct accessったい 121222
PDF
App controllerとwindows azure packで作る大規模プライベートクラウド
PDF
Introducing Windows Terminal
PPTX
System Centerで変わる運用
PDF
App dna step by-stepアプリケーション互換性の検証
Getting started with Windows Containers
20180630 data transformationusinglogicflow
夏サミ2014 クラウドとCIツールで変わるエンタープライズJava開発
System Center Operations Manager 2019
60分でわかる!SilverlightとWPFの入力チェック
System Center 2012, Endpoint Protectionの運用
PowerShell DSC 入門
App controllerとSPFで実現するハイブリッドクラウド
WebSphere Application Server V8.5.5 Libertyプロファイルのご紹介 #jjug_ccc #ccc_r51
ついに始まるJava EE 7時代のアプリケーション開発
Eclipse と Liberty プロファイルで始める Java EE 開発ハンズオン #jjug_ccc #ccc_r51
IBMが新しいJava EEコンテナを作っているらしい -Libertyプロファイルとは-
17-D-1 Azure開発の極意 ~2011年版~
GoodBye AD FS - Azure Active Directory Only の認証方式へ切り替えよう!
Ws2012 directaccessで実現するworkanyshereシナリオ 121208
Direct accessったい 121222
App controllerとwindows azure packで作る大規模プライベートクラウド
Introducing Windows Terminal
System Centerで変わる運用
App dna step by-stepアプリケーション互換性の検証
Ad

Similar to INF-009_PowerShell を 使いこなして、自動化対応 エンジニア になろう!! (20)

PPTX
PowerShell の基本操作とリモーティング&v3のご紹介 junichia
PPTX
SC2012 VMM SP1 Update ヒーロー島 版
PDF
PDF
本格化するクラウド ネイティブに向けて進化する開発プラットフォームと .NET
PDF
Recap: PowerShell Core
PPTX
Windows Azure PHP Tips
PPTX
20070310
PPTX
20140725 tf azure_pack_slideshare
PDF
20200118 scugj goodbye_ws2008-slide
PPTX
Clrh 20121215
PDF
Windows PowerShell 2.0 の基礎知識
PDF
Sc2012概説 120512
PDF
デスクトップ アプリ開発における Visual Studio の進化
PDF
Dep006 クラウド的オンプ
PDF
[Japan Tech summit 2017] APP 001
PPTX
こわくない!Azure 運用管理
PPTX
2.website spark seminar_infra
PPTX
Vsugday2010 summer lt
PDF
【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること
PPTX
最新!Windows Azure Platformアプリケーション開発
PowerShell の基本操作とリモーティング&v3のご紹介 junichia
SC2012 VMM SP1 Update ヒーロー島 版
本格化するクラウド ネイティブに向けて進化する開発プラットフォームと .NET
Recap: PowerShell Core
Windows Azure PHP Tips
20070310
20140725 tf azure_pack_slideshare
20200118 scugj goodbye_ws2008-slide
Clrh 20121215
Windows PowerShell 2.0 の基礎知識
Sc2012概説 120512
デスクトップ アプリ開発における Visual Studio の進化
Dep006 クラウド的オンプ
[Japan Tech summit 2017] APP 001
こわくない!Azure 運用管理
2.website spark seminar_infra
Vsugday2010 summer lt
【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること
最新!Windows Azure Platformアプリケーション開発
Ad

More from decode2016 (20)

PDF
SPL-005_オープンソースから見たマイクロソフト
PDF
SPL-004_Windows 10 開発の舞台裏から学ぶエンジニアの未来
PDF
SPL-003_黒船襲来! 世界DevOps トップ企業 x マイクロソフトによるトークバトル セッション
PDF
SPL-002_クラウド心配性な上司を説得するコツを伝授します ~本当に信頼できるクラウドの構築/運用とは? マイクロソフト クラウド成長の軌跡~
PDF
PRD-009_クラウドの ERP による業務システム開発 ~OData エンド ポイントから Power BI 連携~
PDF
PRD-008_クラウド ネイティブ ERP ~Dynamics AX のアーキテクチャ/環境構築から開発/運用まで~
PDF
PRD-006_機械学習で顧客対応はこう変わる! Azure ML と Dynamics で造る次世代 CRM
PDF
PRD-005_Skype Developer Platform によるアプリケーション開発の最新情報
PDF
PRD-004_ここまでできる! Azure AD と Office 365 連携開発の先進手法
PDF
PRD-002_SharePoint Server 2016 & Online ハイブリッド環境での業務活用
PDF
INF-028_そのエラーやお困りごと、ツールを使えば解決できるかも! ~Sysinternals や OS 標準ツールの徹底活用術~
PDF
INF-027_セキュリティ マニアックス -サイバー攻撃の手口と防御手法- ~敵を知り、己を知れば百戦危うからず~
PDF
INF-026_真のクラウドベース EMM ~マイクロソフトのモビリティ戦略はいかにユニークか~
PDF
INF-025_企業で使える Windows 10 ~現実的なアプリ & デバイス管理~
PDF
INF-024_Windows 10 の展開 ~プロビジョニング? いやワイプ & ロードでしょ!~
PDF
INF-023_マイクロソフトの特権管理ソリューションの全貌 ~永続的な管理者特権の廃止への道~
PDF
INF-022_情報漏えいを責めるべからず。今必要な対策とは? ~Windows 10 セキュリティ機能徹底解説~
PDF
INF-021_実践! Windows as a Service との上手な付き合い方 ~新しい OS 更新管理の徹底解説~
PDF
INF-020_メーカーがおしえてくれない正しいクラウドについて
PDF
INF-019_Nano Server だけでここまでできる! ~極小サーバーの使い方~
SPL-005_オープンソースから見たマイクロソフト
SPL-004_Windows 10 開発の舞台裏から学ぶエンジニアの未来
SPL-003_黒船襲来! 世界DevOps トップ企業 x マイクロソフトによるトークバトル セッション
SPL-002_クラウド心配性な上司を説得するコツを伝授します ~本当に信頼できるクラウドの構築/運用とは? マイクロソフト クラウド成長の軌跡~
PRD-009_クラウドの ERP による業務システム開発 ~OData エンド ポイントから Power BI 連携~
PRD-008_クラウド ネイティブ ERP ~Dynamics AX のアーキテクチャ/環境構築から開発/運用まで~
PRD-006_機械学習で顧客対応はこう変わる! Azure ML と Dynamics で造る次世代 CRM
PRD-005_Skype Developer Platform によるアプリケーション開発の最新情報
PRD-004_ここまでできる! Azure AD と Office 365 連携開発の先進手法
PRD-002_SharePoint Server 2016 & Online ハイブリッド環境での業務活用
INF-028_そのエラーやお困りごと、ツールを使えば解決できるかも! ~Sysinternals や OS 標準ツールの徹底活用術~
INF-027_セキュリティ マニアックス -サイバー攻撃の手口と防御手法- ~敵を知り、己を知れば百戦危うからず~
INF-026_真のクラウドベース EMM ~マイクロソフトのモビリティ戦略はいかにユニークか~
INF-025_企業で使える Windows 10 ~現実的なアプリ & デバイス管理~
INF-024_Windows 10 の展開 ~プロビジョニング? いやワイプ & ロードでしょ!~
INF-023_マイクロソフトの特権管理ソリューションの全貌 ~永続的な管理者特権の廃止への道~
INF-022_情報漏えいを責めるべからず。今必要な対策とは? ~Windows 10 セキュリティ機能徹底解説~
INF-021_実践! Windows as a Service との上手な付き合い方 ~新しい OS 更新管理の徹底解説~
INF-020_メーカーがおしえてくれない正しいクラウドについて
INF-019_Nano Server だけでここまでできる! ~極小サーバーの使い方~

INF-009_PowerShell を 使いこなして、自動化対応 エンジニア になろう!!

  • 2. はじめに Microsoft Azure のみならず、 PowerShell 関連技術の進歩も速いです 実際の 検証、設計、実装 の際は、 本資料だけでなく、マイクロソフトが 提供している Web サイトなどで、 最新状況を ご確認頂けましたら幸いです 2
  • 3. 本セッション の ゴール マイクロソフト製品や、Microsoft Azure では、PowerShell は必須スキルですが、 今後登場する Azure Stack、Nano Server、各種コンテナ技術 では、 ますます PowerShell が使いこなせないと、利用する事が困難になります 本セッションでは、現状の PowerShell 中心に関連技術をご紹介し、 自動化対応 エンジニアを目指される為の参考情報をご提供致します 習得に向けての足掛かりになれれば幸いです 3
  • 4. 本日の内容 • 温故知新:マイクロソフト技術 の 方向性 (一部) • 使いこなせる様になると、こんな事もできる様になる • 昨年 の de:code にて要素技術の位置づけを紹介 • PowerShell 5.0 • WMF に内包? WMF とは? • モジュール&スクリプトの追加で使用範囲が広がる • PowerShell スクリプト 開発ツールは? • PowerShell スクリプト 稼働場所 • PowerShell が扱えるエンジニアとは? 4
  • 5. 5
  • 7. Windows Server 2003 からはじまる、 データセンター管理の自動化を実現するための、 3-5年を要する中長期のロードマップ  XMLをベースとした 自動管理ソリューション  広範な業界サポートによる、 最高の経済性の実現  自己管理可能な アプリケーションの開発を 可能に  リソースの仮想化と動的な 割り当て 2003年開催 の Microsoft Conference 7
  • 9. Merc. Stage ShuttleJob Cache HTTP SQL Feed Store DSS FTP DSI コンセプト 必要なリソース 運用ポリシー運用特性 既存、あるいは 新しいシステム のモデルを作成 モデルに則した システム運用 モデルに則した自動的なリソース 確保とシステム構成 ストレージサーバー ネットワークIT ライフサイクルをつなぐ モデル 2005年~2008年 の DSI 9
  • 10. Azure 登場 & 進化 10
  • 11. Microsoft Azure と Windows Azure Pack の 比較 SystemCenter2012R2とServiceProviderFoundation その他の サービス Service Bus SQL 仮想 マシン Web サイト サービス プラン ユーザー 管理者 ポータル テナント セルフサービ スポータル Web サイト アプリ データ ベース 仮想マシン サービスプロバイダーカスタマー セルフサービス ポータル 共通の管理 エクスペリエンス ワークロードの ポータビリティ クラウドで利用 できるサービス 一貫性のある開発 エクスペリエンス その他 のサー ビス CDN. Media,, etc. Caching Service Bus SQL VM ロール Web サイト Worker ロール Web サイト アプリ データ ベース 仮想マシン 利用者のセルフ サービスポータル Microsoft Azure Microsoft Azure の機能を パッケージ化、 アドオン構築 できる。 WAP 無し でも稼働OK 11
  • 12. ** - TP1 には Web Apps のみ含まれます、* - TP1 には含まれません 2015年5月 の イベント Ignite にて発表 12
  • 13. 見た目も 運転方法も 同じ車ですが。。 例え話:アーキテクチャーの進化 ガソリンエンジンを整備していた エンジニア は、テスラを整備する為には、 新たに勉強しないと 整備する事は出来ない TCO 削減 & 新技術提供を 目的とした Azure は、プラットフォームが進化している オンプレ で培ってきた スケールアップ システム アーキテクチャー に追加して、 クラウド技術 の スケールアウト システム アーキテクチャー を 新たに勉強する必要がある 13
  • 14. さらに進化。。 The Azure Application Platform 14 Build on Dev frameworksBuild on Infrastructure Preview GA “App Creators” Developers Analysts Microsoft Azure LOBSaaSLift & Shift Docker Virtual Machines Stateful and stateless one- off solutions VM ScaleSets Scalable solutions Container Service Scalable, orchestrated Docker images deployed into containers Differentiation Time to valueExisting App Investments Batch Custom High Performance Computing solutions Open Source PaaS Cloud Foundry, Open Shift Service Fabric Custom Microservice- based stateless and stateful solutions Power Apps Graphical design mobile solutions App Service Template based rapid development web, mobile and API solutions Orchestrated workflow based integration solutions LogicWeb/Mob/ API All the goodness of App Service in a dedicated environment Environments 2016年3月 の イベント Build にて発表
  • 15. 15
  • 16. • 提供されるソリューション (2015年5月 時点) • Remote monitoring:リモート監視 • Predictive maintenance:予測的なメンテナンス Azure IoT Suite 16
  • 17. Azure IoT Suite components (Remote monitoring:リモート監視) 17
  • 19. ソースは、GitHub から公開 Azure IoT Suite の構成済みソリューション ドキュメント https://azure.microsoft.com/ja-jp/documentation/articles/iot-suite-what-are-preconfigured- solutions/ Remote monitoring:リモート監視 https://github.com/Azure/azure-iot-remote-monitoring Predictive maintenance:予測的なメンテナンス https://github.com/Azure/azure-iot-predictive-maintenance 19
  • 20. 20
  • 21. 昨年 の de:code 2015 セッション https://channel9.msdn.com/Events/de-code/decode-2015/MOP-005 21
  • 22. 22
  • 23. コマンドシェルの進化と機能の包含 23 cmd.exe command.com 高機能 NT 低機能 DOS/ Win31 2000 XP/2003 Vista/2008 Windows Script Host PowerShell 上では bat / vbs / js も実行可能 Win9x/ Me Win7/ 2008R2 Windows PowerShell 100 200 約 3000 超 コマンドレットの数 Win8/ 2012/R2
  • 24. PowerShell 5.0 24 2012年9月リリース 動作環境: .NET Framework 4.0 ~ 対応OS Windows Server 2012 (標準搭載) Windows Server 2008 SP2 & R2 SP1 Windows 8 (標準搭載) Windows 7 SP1 搭載機能 PowerShell Workflow PowerShell Web Access CIM integration Scheduled Jobs Integration Task Scheduler Integration Core Cmdlets 多数追加 各サーバー製品毎の Cmdlets 多数追加 他多数 2013年10月リリース 動作環境: .NET Framework 4.5 ~ 対応OS Windows Server 2012 R2 (標準搭載) Windows Server 2012 Windows Server 2008 R2 SP1 Windows 8.1 (標準搭載) Windows 7 SP1 搭載機能 PowerShell Desired State Configuration (DSC) PowerShell Web Services PowerShell Web Access 機能強化 PowerShell Workflow 機能強化 PowerShell ISE 機能強化 Core Cmdlets 機能強化/多数追加 各サーバー製品毎の Cmdlets 多数追加 他多数 2015年12月リリース 動作環境: .NET Framework 4.5 ~ 対応OS Windows Server 2016 (標準搭載) Windows Server 2012 & R2 Windows Server 2008 R2 SP1 Windows 10 (標準搭載) Windows 8.1 Windows 7 SP1 搭載機能 PackageManagement (旧称 OneGet) PowerShell DSC 機能強化 PowerShell Web Services Odata 対応 PowerShell ISE 機能強化 セキュリティ機能強化 (JEA Admin) Core Cmdlets 機能強化/多数追加 各サーバー製品毎の Cmdlets 多数追加 他多数 2009年10月リリース 動作環境: .NET Framework 2.0 ~ 対応OS Windows Server 2008 R2 (標準搭載) Windows Server 2008 SP1 Windows Server 2003 SP2 & R2 SP2 Windows 7 (標準搭載) Windows Vista SP1 Windows XP SP3 搭載機能 (一部) Remoting Background Jobs PowerShell ISE GridView スクリプト言語 機能強化 セキュリティ機能強化 Core Cmdlets 多数追加 各サーバー製品毎の Cmdlets 多数追加 他多数 2006年11月リリース 動作環境: .NET Framework 2.0 対応OS Windows Server 2003 SP1 & R2 SP1 Windows Vista Windows XP SP2 搭載機能 (一部) Core Cmdlets 多数登場 PowerShell Provider Script Language 2016年11月14日 PowerShell 10周年 になります
  • 25. 25
  • 26. WMFとは? (1/3) 26 Technology Partner Storage Network DevicesDisk Other ELEMENTS IT Pro IT Developer Solution Developer Windows Management Instrumentation (WMI) CIM, WBEM CIM, WBEM CIM, WBEM CIM, WBEMCIM, WBEM CIM, WBEM
  • 27. WMFとは? (2/3) 27 Windows Management Framework (WMF) Technology Partner Storage Network DevicesDisk Other ELEMENTS IT Pro IT Developer Solution Developer Windows Management Instrumentation (WMI) CIM CIM CIMCIM CIM CIM, WBEMCIM, WBEM CIM, WBEM CIM, WBEMCIM, WBEM CIM, WBEM
  • 28. WMFとは? (3/3) 28 Technology Partner PowerShell CIM Client OData CIM Schema WMI Storage Network DevicesDisk Other ELEMENTS IT Pro IT Developer Solution Developer Windows Management Instrumentation (WMI) Standardized Protocols WS-Management (WS-Man) (WinRM:サーバー側 Windows Remote Management、WinRS: クライアント側 Windows Remote Shell) REST HTTP PSRP (PowerShell Remoting) CIM CIM CIMCIM CIM CIM, WBEMCIM, WBEM CIM, WBEM CIM, WBEMCIM, WBEM CIM, WBEM Windows Management Framework (WMF) PowerShell ISE PowerShell DSC PowerShell Web Services Just Enough Administration PackageManagement (a.k.a. OneGet) PowerShellGet PowerShell Script Debugging Network Switch Management Audit PowerShell Usage using Transcription and Logging Software Inventory Logging etc
  • 29. • WMI: Windows Management Infrastructure • Windows の多くのシステム情報にアクセス可能 • 設定の変更も可能 • WinRM / WinRS(WS-Management) • サーバー側: WinRM (Windows Remote Management) • クライアント側: WinRS (Windows Remote Shell) • システム管理のための Web サービス • HTTP, HTTPS でリモートマシンにコマンド発行が可能 • リモートの WMI にアクセス ローカル、リモート 管理 29 PowerShell WMI WS-Management WMI WS-Management ローカル リモート
  • 30. PowerShell 5.0 & WMF 5.0 新機能 (1/2) 30 PowerShell Web Services Odata 対応 PowerShell ISE 機能強化 セキュリティ機能強化 (JEA Admin) PowerShell クラス定義 (プロパティ、メソッド) PowerShell .NET 列挙型 コミュニティからの要望があった コマンドレット の新規追加&機能強化 ODataUtils と OData エンドポイント の コマンドレット を追加 ZIP アーカイブ の コマンドレット を追加 シンボリック リンク操作 の コマンドレット を機能強化 Network スイッチ の コマンドレット を追加 PowerShell ISE で DSC の作成機能の強化 DSC の コンフィグレーション キーワード に 32-ビット をサポート PowerShell の使用状況をロギングする監査機能強化 テキストデータを構造化オブジェクトへ変換 DSC LCM (Local Configuration Manager) バージョン 2.0 DSC の LCM (Local Configuration Manager) に メタ構成属性 も構成可能 DSC の コンフィグレーション内を部分的に分割定義可能 DSC でコンピューター間の依存関係を管理可能 DSC の構成をより細かく制御可能 DSC の構成状態についての詳細把握可能 DSC のデバッグ機能強化 DSC RunAsCredential のサポート DSC LCM の情報追加 DSC リソース のサイド バイ サイド インストール DSC からの構成ステータス レポートを集中収集可能 PSDesiredStateConfiguration モジュールを 1.1 にバージョンアップ PackageManagement (旧称 OneGet) で、ソフトウェアを検索&インストール PowerShellGet モジュール で、PowerShell Gallery を 検索&ダウンロード&インストール&可能 PowerShell で、クラスの開発可能 PowerShell 実行空間リモート プロセスのデバッグ PowerShell のバック グラウンド ジョブのデバッグ ソフトウェア インベントリ の ログ収集可能 CMS (Cryptographic Message Syntax) にて、RFC5652 準拠の 暗号化/複合化を追加 16進数 (Hex) 対応フォーマット追加 テンポラリーファイル 作成可能 クリップボード の操作可能 GUID 生成可能 ゴミ箱 操作可能 レジストリ値 を直接取得可能 Job や Workflow にて、ストリーム情報が追加 テキスト文章作成時の改行追加不可 フォルダ検索時の階層段階制御 ローカル と リモート間でのファイル コピー機能 Nano Server 対応
  • 31. PowerShell 5.0 & WMF 5.0 新機能 (2/2) New features in Windows PowerShell 5.0 https://technet.microsoft.com/en-us/library/hh857339.aspx#BKMK_new50 Windows Management Framework 5.0 Production Preview is now available https://blogs.msdn.microsoft.com/powershell/2015/08/31/windows-management- framework-5-0-production-preview-is-now-available/ Windows Management Framework (WMF) 5.0 RTM is now available https://blogs.msdn.microsoft.com/powershell/2015/12/16/windows-management- framework-wmf-5-0-rtm-is-now-available/ Windows Management Framework (WMF) 5.0 currently removed from Download Center https://blogs.msdn.microsoft.com/powershell/2015/12/23/windows-management- framework-wmf-5-0-currently-removed-from-download-center/ Windows Management Framework 5.0 ダウンロードセンター https://www.microsoft.com/en-us/download/details.aspx?id=50395 31
  • 32. PackageManagement Architecture (旧OneGet) 32 End User PackageManagement PowerShell cmdlets PackageManagement Core Discovery Install/Uninstall Inventory PackageManagement Providers Windows Server App (WSA) PowerShellGet Windows Container NuGet NanoServerPackage … Package Sources WSA Package Repository… PowerShell Gallery Container Gallery, Docker NuGet Gallery … www.NPMjs.com WordPress, … Documentation https://technet.microsoft.com/en-us/library/mt422622.aspx PackageManagement and NuGet provider source are in GitHub http://oneget.org
  • 34. 34
  • 35. • PowerShell の実行単位は、コマンドレット • モジュールは、製品単位や、機能単位に、コマンドレット&他 をパックにした物 • モジュール内に格納されている コマンドレット一覧を見る時:Get-Command -Module PowerShellGet • モジュールがインポートされていないとコマンドレットは使用できない • 機能を使用したい場合、モジュールを ダウンロード → インストール → インポート する • PowerShell 5.0 からの PowerShellGet モジュール 内の Install-Module にて、PowerShell Gallery から、ダウンロード&インストールが可能になった • インストール後に、Import-Module コマンドレット にてインポート • バッチファイル の様に、行単位にコマンドレットを記述し、行単位に実行される • 一般的なスクリプト言語と同じく、変数、繰返し文、条件文制御構文、配列、エラー処理などを 使用して高度な処理を行う事も可能 モジュール&スクリプトを追加すると使用範囲が広がる (1/3) 35 モジュール自体の開発を行いたい時:Writing a Windows PowerShell Module https://msdn.microsoft.com/en-us/library/dd878310.aspx
  • 36. モジュール&スクリプトを追加すると使用範囲が広がる (2/3) モジュール の メジャーバージョンは、 Web PI (Web Platform Installer) から、ダウンロード&インストール https://www.microsoft.com/web/downloads/platform.aspx 36
  • 37. モジュール&スクリプトを追加すると使用範囲が広がる (3/3)Microsoft から提供する 各製品&サービス の PowerShell 関連 の モジュール&スクリプトは、PowerShell Gallery に 掲載されていきます Microsoft 社外の方々が作成された モジュール&スクリプト を アップロード&公開 も可能 https://www.powershellgallery.com/ 37
  • 38. 38
  • 39. • Windows PowerShell 専用エディタ • スクリプトおよびモジュールを記述, 実行, テストができるホスト アプリケーション • 構文の色指定, タブ補完, 視覚的なデバッグ機能, ユニコード準拠, 状況依存のヘルプなどの 主要な機能により、多彩なスクリプトの操作性を提供 • 対話型のコマンドを実行できるコマンドペイン • コマンドの出力をキャプチャする出力ペイン • 関数, スクリプト, モジュールを作成, 編集, デバッグ, 実行するためのスクリプト ペイン • 複数の独立タスクを同時実行できる PowerShell タブ (Ctrl + T) • Powershell_ise.exe は、Windows 7 以降搭載 • IntelliSense, Snippets に対応 PowerShell スクリプト 開発ツール(1) Windows PowerShell ISE (Integrated Scripting Environment) 39
  • 40. PowerShell スクリプト 開発ツール(2) Visual Studio Code 40 Visual Studio Code は、 Windows, Linux, OS X のお好きな プラットフォームで無料で利用可能 Visual Studio Codeは、 30 以上の言語に対応サポート https://www.visualstudio.com/products/code-vs https://marketplace.visualstudio.com/VSCode
  • 42. PowerShell スクリプト 開発ツール(2) Visual Studio Code Announcing PowerShell language support for Visual Studio Code and more! https://blogs.msdn.microsoft.com/powershell/2015/11/16/announcing-powershell- language-support-for-visual-studio-code-and-more/ Visual Studio Code ホームページ https://www.visualstudio.com/products/code-vs Visual Studio Code Marketplace https://marketplace.visualstudio.com/VSCode Visual Studio Code 取扱説明書 https://code.visualstudio.com/docs Debugging (launch.json 解説) https://code.visualstudio.com/docs/editor/debugging 42
  • 43. PowerShell スクリプト 開発ツール(3) Visual Studio (Enterprise / Professional / community) 43 [ツール]-[拡張機能と更新プログラム] から、 オンライン での、[PowerShell] で検索して、 PowerShell Tools for Visual Studio 2015 をインストール PowerShell Tools for Visual Studio 2015 https://visualstudiogallery.msdn.microsoft.com/ (PowerShellで検索)
  • 44. PowerShell Tools for Visual Studio 2015 44
  • 45. PowerShell スクリプト 開発ツール(3) Visual Studio (Enterprise / Professional / community) 45 Visual Studio の 各エディション の PowerShell Tools for Visual Studio 2015 対応表 エディション 無料/有料 PowerShell Tools for Visual Studio 使用可否 備 考 Visual Studio Enterprise 2015 有料 使用可能 Visual Studio Professional 2015 有料 使用可能 Visual Studio Community 2015 無料 使用可能 ●個人用 個人開発者の方はどなたでも、独自の無料/有料のアプリを作成するために Visual Studio Community を使 用できます。 ●組織用 組織が学習環境のクラスルームで、アカデミックな研究のため、あるいはオープン ソース プロジェクトに寄 与するために、Visual Studio Community を使用する場合には、ユーザー数に制限はありません。 ●それ以外の使用シナリオ エンタープライズ以外の組織では最大 5 ユーザーで Visual Studio Community を使用できます。 エンタープライズ組織 (>PC 250 台>または年間売上が 100 万米ドルの組織) については、オープン ソース、 アカデミックな研究、学習環境のクラスルームといった前述のシナリオ以外で使用することはできません。 Visual Studio Express 2015 for Desktop 無料 使用不可 ●Express 製品の商業目的の使用 Visual Studio Express 製品は、各製品のライセンス条項に従うことを条件として、無料で商用、製造用に使 用できます。 たとえば、Express for Windows を使用してアプリを作成し、Windows ストアで販売するこ とができます。 Visual Studio Express 2015 for Web 無料 使用不可 Visual Studio Express 2015 for Windows 10 無料 使用不可 Visual Studio ダウンロード https://www.visualstudio.com/downloads/download-visual-studio-vs Visual Studio Community 2015 ライセンス条項 https://www.visualstudio.com/support/legal/mt171547 Visual Studio Express 2015 ライセンス条項 https://www.visualstudio.com/support/legal/mt171551
  • 46. PowerShell スクリプト 開発ツール(3) Visual Studio (Enterprise / Professional / community) 46 Visual Studio 2015 製品の比較 https://www.visualstudio.com/products/ compare-visual-studio-2015-products-vs
  • 47. 47
  • 48. PowerShell スクリプト稼働場所 48 Microsoft Azure Azure Stack オンプレミス IaaS ゲスト OS (ノード) 内部構成 LCM:PowerShell DSC Local Configuration Manager IaaS ゲスト OS (ノード) 内部構成 ゲスト OS (ノード) 内部構成
  • 50. PowerShell DSC の 構成機能 伝統的なスクリプト 特定の技術 DSC Engine 依存関係の解決 ログ&エラー処理 再起動にも対応 反復処理も可能 Resources 実行される処理 Configuration Intent (目的) 50
  • 51. PowerShell スクリプト と PowerShell DSC との違い  PowerShell スクリプト Import-Module ServerManager # IIS (Web Server) IIS がインストールされているか否かを確認して、 未インストールであれば、IIS をインストールする $feature = Get-WindowsFeature -Name Web-Server if(($Ensure -eq "Present") -and (!$feature.Installed)) { Install-WindowsFeature -Name Web-Server }  PowerShell DSC Configuration Install-IIS { Node localhost { WindowsFeature IIS { Ensure = "Present" Name = “Web-Server" } } } 例:IIS の 追加インストール PowerShell スクリプト では、手順を全てコーディングする必要があるので、 インストールされているか否か の 条件も考慮して コーディングする必要がある PowerShell DSC では、望まれた結果(結果の状態) を パラメータ として記述する Ensure = “Present” で、状態の結果は、IIS がインストール済みを表す DSC では、状態の結果を 宣言的に構文を記載するので、条件文は存在しない ※リソースを開発する際には、Configuration 側では条件文を書かない事を考慮する必要がある (何度実行してもエラーにならない ロジックを リソース内に開発する必要がある) Configuration と記述して、 DSC の 宣言的構文 を 記述 Install-WindowsFeature は、 Windows Server の機能追加を行う コマンドレット WindowsFeature は、 PowerShell DSC の 標準リソースで、 Windows の追加機能名を パラメータとして記載 51
  • 52. • PowerShell DSC の リソース自体は、PowerShell スクリプト なので、個別に独自開発する事が可能 • DSC Resource Kit (All Modules:Wave10) 2015/8/8 Update • https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d • 48モジュール • DSC Resource Kit Update 2016/4/4 • https://blogs.msdn.microsoft.com/powershell/2016/04/04/dsc-resource-kit-update/ • 48の内、21モジュールをアップデート、6モジュール追加、Total 279 リソース • ダウンロードは、PowerShell Gallery から行う PowerShell DSC の リソース 52
  • 53. Push型 と Pull型 Push 型 管理サーバーから 設定情報を送る Pull 型 定期的に 管理サーバーに問い合わせ 望まれた状態に、自動的に構成し続ける事が可能一時的or継続的に管理サーバの トリガー (人的 orスケジュール) により、自動構成する Push and Pull Configuration Modes http://blogs.msdn.com/b/powershell/archive/2013/11/26/push-and-pull-configuration-modes.aspx 53
  • 54. 自動構成ツール の 使い処 ●Microsoft Azure / Stack Azure Resource Manager Azure Automation ●オンプレミス System Center Orchestrator 仮想マシンの外側か内側かで 自動化の目的が異なる PowerShell DSC Chef Puppet 54
  • 55. PowerShell DSC の Pull サーバー Configuration (script) DSC Resources コード作成/編集 MOF MOF Node Configuration (MOF) Zip Zip Zip ステージング コンパイル Zip Azure 仮想マシン 物理 サーバー オンプレミス 仮想サーバー MOF MOF Node Configuration (MOF) Zip Zip Zip Rest Endpoint レポート データ 55
  • 56. Azure Automation DSC (Pull のみ , Push なし) Configuration (script) DSC Resources MOF MOF Node Configuration (MOF) Zip Zip Zip レポート Azure 仮想マシン 物理 サーバー オンプレミス 仮想サーバー Rest Endpoint コード作成/編集 ステージング Azure Automation 56
  • 57. Azure Automation 自動処理タスク Runbook (PowerShell) タスクを オンデマンド配信 処理状況監視 ログ管理 Azure の各機能や、サードパーティーから 提供されている PowerShell を利用可能 運用コスト削減する柔軟なプロセス ワーク フロー PowerShell DSC 対応 インターネットからの実行可能 Azure から オンプレミスへ 実行可能 プロセス最適化 &拡張 管理ポータルに テキスト/グラフィカル の エディターを用意 ライブラリより、コマンドレッドや Runbook、アセット を一覧できるライブラ リを用意 管理ポータルより 作成&編集が可能 オペミス削減によるコスト削減&システム 信頼性向上 スケーラブルな高可用性の要求を満たす実 行環境を提供 起動方法:スケジュール機能、Webhooks、 PowerShell (Start-AzureAutomationRunbook) 運用作業におけるコ スト削減 統合 編集 Automation Azure Automation 編集 実行統合 57
  • 58. Azure Automation の ギャラリ参照(1/3) 58 https://gallery.technet.microsoft.com/
  • 59. Azure Automation の ギャラリ参照(2/3) 59 Azure 管理 ポータル
  • 60. Azure Automation の ギャラリ参照(3/3) 60 Azure 管理ポータル (クラシック )
  • 61. 61
  • 62. • PowerShell は開発言語です • コマンドレットだけを並べても、自動化処理は行えません • 実際の業務では、自分が毎回新規コーディングする事はなく、他人がコーディン グしたソースを読んで、潜んでいるバグを発見&修正するスキルが必要 • サンプル ソース の 読解力も必要 • 手作業の最中に、頭で判断、単純繰り返し作業など を人的に行っていた事を PowerShell スクリプト へ、書き替える開発も多いです • PowerShell は、開発言語なので。。。 パラメーター , 変数 , 文字列 , 型 , 配列 , 演算式 , 条件文 , 繰返し処理 , 関数 , パイプライン , リダイレクト , ワイルドカード , エラー処理 , などなど 基礎中の基礎を知っておかないと、読み 書き は、できません PowerShell が扱えるエンジニアとは? 62
  • 63. 『ARMではじめるMicrosoft Azureの新規構築・運用管理の自動化』 コース提供が、始まります!! • Azure PowerShell や Azure Resource Manager テンプレートを使った デプロイや運用管理の基礎を学べる入門コースです • プログラム初学者、苦手な方に向けて PowerShell・JSON の基本構文から トラブルシューティングまでわかりやすくご紹介します! • 前編/後編 の e-Learning +手元 で動作確認するための手順書で 実践しながら学習できます 詳細は http://www.knowledgewing.com/arm/ から 開発&提供:2016年6月 1日:お申込み受付開始予定 2016年6月27日:開講予定
  • 65. PowerShell 学習教材 65 • Windows PowerShell でのスクリプティング https://technet.microsoft.com/ja-jp/scriptcenter/dd742419.aspx • Azure Cmdlet Reference https://msdn.microsoft.com/en-us/library/azure/jj554330.aspx 最新情報は、 Get-Help コマンドレット 例:Get-Help Import-Module -Full
  • 66. PowerShell 技術情報 (1/2) 66 PowerShell Blog PowerShell の最新情報はココから https://blogs.msdn.microsoft.com/powershell/ PowerShell on User Voice PowerShell 開発チームへ直接リクエストできます https://windowsserver.uservoice.com/forums/301869-powershell 同じ要望があれば、投票ボタンを押します カウント数が多い事案から、開発チームが検討します
  • 67. PowerShell 技術情報 (2/2) 67 PowerShell 開発チーム の GitHub https://github.com/powershell
  • 69. • Linux 用 PowerShell DSC 使用方法 • https://msdn.microsoft.com/ja-jp/powershell/dsc/lnxgettingstarted • 以下の Linux をサポート • CentOS 5、6、および 7 (x86/x64) • Debian GNU/Linux 6 および 7 (x86/x64) • Oracle Linux 5、6 および 7 (x86/x64) • Red Hat Enterprise Linux Server 5、6 および 7 (x86/x64) • SUSE Linux Enterprise Server 10、11、および 12 (x86/x64) • Ubuntu Server 12.04 LTS および 14.04 LTS (x86/x64) • DSC サーバー側 • Open Management Infrastructure (OMI) CIM サーバーのバージョン 1.0.8.1 が必要 • https://collaboration.opengroup.org/omi/ からダウンロード • ゲスト OS (ノード)側 • PowerShell Desired State Configuration for Linux をインストール https://github.com/Microsoft/PowerShell-DSC-for-Linux/releases/tag/v1.1.1-70 Linux 用 PowerShell Desired State Configuration (DSC) 69
  • 70. お互い Windows も Linux の両方が対象なので、 どちらを選択したら良いか? • 既存資産 or 今後の環境 で、Windows と Linux の保有台数で選択 • 既にどちらかを使用しているのであれば、慣れている方を選択 • DSC 以外の自動化機能も利用するなら、その比率も考慮して選択 PowerShell DSC と Chef / Puppet の選択 (案) 70
  • 72. Azure Automation ラーニング パス 72 https://azure.microsoft.com/ja-jp/documentation/learning-paths/automation/
  • 74. ま と め PowerShell が 読み 書き 出来る様になるだけで、 仕事の幅がイッキに広がります システム設計&運用設計、構築&テスト作業&運用作業 など の手法なども進化し、無くなる既存作業、これまで無かった 新しい作業も現れます システム設計、運用設計、構築&テスト作業、 運用作業などの工数を激減させる事も可能です 楽になった分、新しいクラウド技術を勉強する 時間に割り当てましょう (^O^)/ 74
  • 75. 75
  • 77. • PowerShell 自体 のバージョン • PowerShell ISE などから $PSVersionTable を実行 • Azure PowerShell の バージョン • PowerShell ISE などから Get-Module -ListAvailable を実行 • 最新のバージョンは いくつ? https://github.com/Azure/azure-powershell/releases • 最新バージョンのインストールは、Web PI から実行 お手元のPC内の バージョン確認方法は? 77
  • 78. • どの様なDSC Resource がある? • Get-DscResource • 見つけたDSC Resource の プロパティ構成は? • Get-DscResource -Name WindowsFeature | Select-Object -ExpandProperty Properties • Get-DscResource -Name WindowsFeature | % Properties # 省略形 • 見つけたDSC Resource の プロパティ構成は? • Get-DscResource -Name WindowsFeature –Syntax または PowerShell ISE で記述時に、IntelliSense (Ctrl+Space) DSC Configuration 構文の調べ方 78
  • 79. • DSC Resource Kit Update 2016/4/4 • https://blogs.msdn.microsoft.com/powershell/2016/04/04/dsc-resource-kit-update/ • 48の内、21モジュールをアップデート、6モジュール追加、Total 279 リソース • ダウンロードは、PowerShell Gallery から行う • DSC Resource Kit Anniversary Release 2016/5/18 • https://blogs.msdn.microsoft.com/powershell/2016/05/18/dsc-resource-kit-anniversary- release/ • 52 モジュールの内、23 モジュールをアップデート、23 モジュール追加、Total 302 リソース • ダウンロードは、PowerShell Gallery から行う スライド 52 の アップデート 79
  • 80. Azure Automation PowerShell ISE add-on 80 • Azure Automation PowerShell ISE アドオンを発表 https://blogs.technet.microsoft.com/jpitpro/2016/01/19/azur e-automation-powershell-ise/ • Announcing the Azure Automation PowerShell ISE add-on https://azure.microsoft.com/ja-jp/blog/announcing-azure- automation-powershell-ise-add-on/ • Introducing Service Management Automation ISE add-on https://blogs.technet.microsoft.com/orchestrator/2016/04/2 8/introducing-service-management-automation-ise-add-on/ • Azure Automation PowerShell ISE Add-On https://github.com/azureautomation/azure-automation-ise- addon
  • 81. • チェックポイントを活用して、 信頼性の高いフォールト トレラントな Runbook を実行 • https://blogs.msdn.microsoft.com/windowsazurej/2014/09/11/azure-automation-1254/ • ページ内は、30分 と記載されていますが、現在は機能拡張して 3時間 です。 • 3時間 記載は、コチラ。(2016年3月21日 公開) Azure Automation での Runbook の実行 • https://azure.microsoft.com/ja-jp/documentation/articles/automation-runbook- execution/#-2 • 実行開始タイミングは、コチラ。(2016年1月 公開) Automation の SLA • https://azure.microsoft.com/ja-jp/support/legal/sla/automation/v1_1/ Azure Automation お作法 (フェア シェア) 81
  • 82. • WMI Architecture https://msdn.microsoft.com/en-us/library/aa394553(v=vs.85).aspx • Windows Remote Management Architecture https://msdn.microsoft.com/en-us/library/aa384464(v=vs.85).aspx • Windows PowerShell Desired State Configuration の組み込みリソース https://msdn.microsoft.com/ja-jp/powershell/dsc/builtinresource 参考URL 82
  • 83. • 1インスタンスにて、Local Host の構成を行う デモで使用したスクリプト:PowerShell DSC (1/6) 83 # DSC のローカル の構成内容 Configuration ConfigIISInstall { Import-DscResource –ModuleName "PSDesiredStateConfiguration" Node $Node { WindowsFeature IIS { Name = "Web-Server" Ensure = "Present" } } } # MOF ファイル作成 $Node = "localhost" ConfigIISInstall -OutputPath C:¥Users¥yoshiazu # Local Host に適用 Start-DscConfiguration -Path C:¥Users¥yoshiazu -Wait -Verbose
  • 84. • Push / Pull にて、サーバー(ローカル) と 各ノード(リモート)を WS-Management にて、CIM セッションを確立する デモで使用したスクリプト:PowerShell DSC (2/6) 84 # Push / Pull ローカル側の作業 リモート側の作業は無し) # 管理者モードで以下を実行 # ドメイン配下での場合 Enable-PSRemoting # ドメインが無い場合は、信頼できるホストを指定する (ワイルドカード使用可) Set-Item wsman:¥localhost¥Client¥TrustedHosts -Value * -Force # 設定確認 Get-Item -Path "wsman:¥localhost¥Client¥TrustedHosts" # CIM セッション確立 New-CimSession -ComputerName de16-DSC-Push-C,de16-DSC-Push-D # 確立されている CIM セッションの確認 Get-CimSession
  • 85. • Push にて、サーバーから、各ノード の LCM (PowerShell DSC Local Configuration Manager) の設定を行う デモで使用したスクリプト:PowerShell DSC (3/6) 85 [DSCLocalConfigurationManager ()] Configuration LCMConfigPush { Node $Node { Settings { AllowModuleOverwrite = $True ConfigurationMode = 'ApplyAndAutoCorrect' # ApplyAndMonitor → ApplyAndAutoCorrect ConfigurationModeFrequencyMins = 30 # 15 → 30 RefreshMode = 'Push' RebootNodeIfNeeded = $True } } } # Meta MOF ファイル作成 $Node = 'de16-DSC-Push-C','de16-DSC-Push-D' LCMConfigPush -OutputPath C:¥Users¥yoshiazu # 各ノード に適用 Set-DSCLocalConfigurationManager -ComputerName $Node -Path C:¥Users¥yoshiazu –Verbose # LCM 内の設定情報を確認 Get-DscLocalConfigurationManager -CimSession $Node
  • 86. • Push サーバーから、各ノードへ構成を行う デモで使用したスクリプト:PowerShell DSC (4/6) 86 # DSC Pushサーバー の 各ノードへの構成内容 Configuration ConfigIISInstall { Node $Node { WindowsFeature IIS { Name = "Web-Server" Ensure = "Present" } } } # MOFファイル作成 $Node = "de16-DSC-Push-C","de16-DSC-Push-D" ConfigIISInstall -OutputPath C:¥Users¥yoshiazu # 各ノード に Push適用 Start-DscConfiguration -Path C:¥Users¥yoshiazu -ComputerName $Node -Wait –Verbose
  • 87. • Pull サーバー構築 デモで使用したスクリプト:PowerShell DSC (5/6) 87 configuration PullServerHttp { Import-DSCResource -ModuleName xPSDesiredStateConfiguration Node $Node { WindowsFeature DSCServiceFeature { Ensure = "Present" Name = “DSC-Service” } WindowsFeature IISConsole { Ensure = "Present" Name = “Web-Mgmt-Console” } xDscWebService PSDSCPullServer { Ensure = "Present" EndpointName = "PSDSCPullServer" Port = 8080 PhysicalPath = "$env:SystemDrive¥inetpub¥wwwroot¥PSDSCPullServer" CertificateThumbPrint = "AllowUnencryptedTraffic" ModulePath = "$env:PROGRAMFILES¥WindowsPowerShell¥DscService¥Modules" ConfigurationPath = "$env:PROGRAMFILES¥WindowsPowerShell¥DscService¥Configuration" State = "Started" DependsOn = "[WindowsFeature]DSCServiceFeature" } } } # MOF ファイル作成 $Node = "localhost" PullServerHttp -OutputPath C:¥Users¥yoshiazu # Local Host に適用 Start-DscConfiguration -Path C:¥Users¥yoshiazu -ComputerName localhost -Verbose -Wait
  • 88. • Pull にて、サーバーから、各ノード の LCM (PowerShell DSC Local Configuration Manager) の設定を行う デモで使用したスクリプト:PowerShell DSC (6/6) 88 [DSCLocalConfigurationManager()] Configuration LCMConfigPull { param ( [Parameter(Mandatory=$true)] [string[]]$ComputerName, [Parameter(Mandatory=$true)] [string]$guid ) Node $Node { Settings { AllowModuleOverwrite = $True ConfigurationMode = 'ApplyAndAutoCorrect' RefreshMode = 'Pull' ConfigurationID = $guid } ConfigurationRepositoryWeb DSCHTTP { ServerURL = 'http://de16-dsc-http-s:8080/PSDSCPullServer.svc/' #CertificateID = 'D0916BFB09B40E7568A74' AllowUnsecureConnection = $true } } } # Meta MOF ファイル作成 $Node = 'de16-DSC-Http-C' $guid=[guid]::NewGuid() LCMConfigPull -ComputerName $Node -Guid $guid -OutputPath C:¥Users¥yoshiazu # 各ノード に適用 Set-DSCLocalConfigurationManager -ComputerName $Node -Path C:¥Users¥yoshiazu –Verbose # LCM 内の設定情報を確認 Get-DscLocalConfigurationManager -CimSession $Node
  • 89. 89