18
Windows PowerShellを紐解く 2015年1月24日 株式会社アスラ 林 茂之 (WBEMとWindows PowerShellの管理機能) I try to tease the Windows PowerShell .NETラボ 勉強会 2015年1月

03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

Embed Size (px)

Citation preview

Page 1: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

Windows PowerShellを紐解く

2015年1月24日株式会社アスラ 林 茂之

(WBEMとWindows PowerShellの管理機能)

I try to tease the Windows PowerShell

.NETラボ 勉強会 2015年1月

Page 2: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

自己紹介

氏名 林 茂之 (はやし しげゆき)

年齢 46歳

興味 おもちゃ屋さん、ガンダム、攻殻機動隊矢沢永吉、Miles Davis 、Bill Evans まゆゆ(AKB48)→ 推し歴5年

仕事 顧客先にて、インフラ(基盤)構築を中心にやってます。顧客からの要望で、プロジェクトマネージャもやります。これまでは、外資証券、地方自治体、情報通信、商社、保険、銀行、官公庁といった業界で仕事をしてきました。

ここ2年ほど、EDI(Electronic Data Interchange:電子データ交換)の仕事ですっかりWindowsから離れてました(汗

Page 3: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

DMTFとWBEMとCIM

Distributed Management Task Force, Inc. (DMTF)

1992年に設立されたDMTF(Distributed Management Task Force)は、IT業界の企業が協力してシステム管理標準を開発、検証、促進、導入していくための団体WBEMやCIMといった定義を公表している

参考 http://www.dmtf.org/jp

Page 4: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

Webベースのエンタープライズ環境の管理(WBEM)は、分散コンピューティング環境を一元管理するために開発された一連の管理技術およびインターネット標準技術。

WBEMは、緊密に統合された標準ベースの一連の管理ツールを提供する能力を業界に提供して、本来は完全に異なるテクノロジーやプラットフォーム上でデータを容易に交換できるようにすることを目標としている。

WBEMにはCIM実装を発見しアクセスするプロトコルが含まれている。

DMTFとWBEMとCIM

Web-Based Enterprise Management (WBEM:ダブリューベム)とは何か

参考 http://ja.wikipedia.org/wiki/Web-Based_Enterprise_Management

Common Information Model (CIM:シム)とは何か

IT環境における管理対象を典型的なオブジェクトとその関係で表現する方法を定義したオープン標準である。これにより、そうした管理対象をメーカーに関わらず一貫して管理することを意図している。

Page 5: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

集中処理と分散処理の歴史

1980年代 2000年代

集中型

分散型

クライアント専用端末

クライアント

専用アプリケーション

クライアントブラウザ

ネットワーク専用ネットワーク

ネットワークLAN

ネットワークLAN

インターネット

クライアントブラウザ

1990年代 2010年代

Page 6: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

WBEMの実装例

出典 http://ja.wikipedia.org/wiki/Web-Based_Enterprise_Management

オペレーティングシステムにおけるWBEMの実装

技術名称 実装例

1 WMI(Windows Management Instrumentation)

マイクロソフト社のWindowsに実装されている。

2 Solaris WBEM Services オラクル社のSolarisに実装されている。

3 HP WBEM Services for HP-UX ヒューレットパッカード社のHP-UX 11iv1以降より実装されている。

4 OpenWBEMノベル社によるオープンソース実装。SUSE Linux Enterprise Serverに実装されている。

5 CimBioteギークネット社により運営されているSourceForge.netにより開発された。Red Hatに実装されている。

WBEMクライアントの実装PyWBEMPurgosSBLI CIM Client for JAVA

クライアントとサーバの実装OpenPegasusOpenWBEM

Page 7: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

コマンドラインインタプリタ

コマンドラインインタプリタに文字列の形でコマンドを入力することでコンピュータを直接操作する。

またコマンドを並べたスクリプトを書いて実行することができる。

コマンドラインインタプリタ

対話モードとバッチモードの二種類のモードを持つ。

対話モードではユーザの入力を即時に実行する。

バッチモードではバッチファイルと呼ばれる拡張子".BAT"のファイルに書かれたコマンドを順次実行する。

拡張可能なコマンドラインインターフェース (CLI)

Windows OSやMicrosoft製品のシステム管理や自動化を行うための新世代シェル。スクリプトとして実行可能なプログラミング言語である。

オブジェクト指向に基づいて設計されており、.NET Framework 2.0 を基盤としている。

Windows PowerShellとは何か

Page 8: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

80年代後半~90年代

2000年代

2010年代

COMMAND.COM

MS-DOS

WindowsNT

cmd.exe Windows 2000 Server

Windows98

WHS(Windows Script Host)

Windows Server 2003(R2)

Windows Server 2008(R2)

Windows Server 2012(R2)

Windows Server vNext

PowerShell 1.0

PowerShell 2.0

PowerShell 3.0

PowerShell 4.0

PowerShell 5.0COMMAND.COMからWindows PowerShellへの変遷

Page 9: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

WMIとPowerShell

PowerShellはWBEMの考えに基づいて実装されたWMI (Windows Management Instrumentation)を利用してオブジェクトを操作する

•コマンドレット

•各種Module

PowerShell

• WMIプロバイダ

• CIM Repository

• WMS

WMI•Redistry

•Event Log

•Cluster

•IIS

Object

WMI :ローカル及びリモートサーバーを管理するために使用されるWindows OS のインターフェース

Page 10: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

オブジェクトとは何か?

オブジェクトとはクラスという設計図を基にして、それを実体化(インスタンス化)したもの

Processクラス

プロパティ ProcessNameIdCPU(s)・・・・・

Processオブジェクト

ProcessName=iexploreId=5964CPU(s)=9.77・・・・・

Processオブジェクト

ProcessName=OUTLOOKId=2844CPU(s)=26.33・・・・・

Processオブジェクト

ProcessName=POWERPNTId=5984CPU(s)=26.86・・・・・

インスタンス化

たとえばプロセス(Process)を例にすると

Page 11: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

コマンドレット(Cmdlet)とモジュール

PowerShellで使用するコマンドレットとは

コマンドレット : PowerShellに用意された命令(Command)であり、最少(let)の実行単位モジュールにパッケージされて提供される

Azure Module Hyper-V Module

コマンドレット

Get-AzureAutomationAccount

Get-AzureAutomationJob

Get-AzureAutomationRunbook

New-AzureAutomationRunbook

Remove-AzureAutomationRunbook::

コマンドレット

Get-VMGet-VMHostAdd-VMSwitchConvert-VHDEnable-VMMigration::

Page 12: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

PowerShellの書式

PowerShellコマンドレットの構造

動詞 名詞―

PowerShellコマンドレットの使用例

+ プロセス情報の取得では

Get-Process

Get-Process –Name explorer

Get-Process –Id 2844

ProcessNameで explorerとされているものの情報を抽出する

Id で 2844 とされているものの情報を抽出する

動詞 名詞

パラメータ名 パラメータ値

パラメータ名 パラメータ値

Page 13: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

PowerShellの書式

PowerShellコマンドレットの基本的な使用例

パラメータを指定しない場合Processオブジェクトすべてが表示される

パラメータを指定せず現在使用可能なProcessオブジェクトをすべて表示する

Page 14: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

PowerShellの書式

PowerShellコマンドレットの基本的な使用例 Outlookのプロセスの存在を確認

Outlookのプロセスを停止しした後、プロセスの存在を確認

Outlookのプロセスを起動

Page 15: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

Windows PowerShellによるシステム管理

+ クラウド環境

WindowsPower Shell

ExchangeOnline

LyncOnline

Office365PRO

Buisiness

SharePointOnline

WindowsAzure AD

WindowsPower Shell

Hyper-V

SystemCenter

IIS

Active Directory

DNS

WindowsServer

+ オンプレミス環境

VMwarePower CLI

調査中

Page 16: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

PowerShell DSC for Linuxによるシステム管理

Power ShellDSC

LinuxCent OS

LinuxSUSE

LinuxUbunts

DSC ・・・ Desired State Configuration

PowerShell DSC: Windows Server 2012 R2 と同時期にリリースされた構成管理の自動化ツール

物理ホスト、仮想マシン、オンプレミス、クラウドなどWindowsインフラ環境において、Windowsサーバー自身を「あるべき状態(Desired State)に構成(Configuration)する」ための自動化プラットフォーム

コマンドレット例

nxUser ・・・ Linuxユーザ管理nxGroup ・・・ Linuxグループ管理

Page 17: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

Windows PowerShell Command Builder のご紹介

http://blogs.technet.com/b/sharepoint_support/archive/2011/10/18/windows-powershell-command-builder.aspx

http://www.microsoft.com/resources/technet/en-us/office/media/windowspowershell/windowspowershellcommandbuilder.html

SharePointの管理をPowerShellで行うようになった。

柔軟な管理ができるようになった (^-^)

対応する操作が多くて覚えきれない orz

Page 18: 03_Windows powershellを紐解く 20150124(the wbem and windows powershell management function_2)

まとめ

1.WBEMの目指すもの・分散コンピューティング環境を一元管理する技術標準の提供・異なるテクノロジーやプラットフォーム上でデータを容易に交換できる技術の提供

2.マイクロソフトの実装・ローカル及びリモートサーバーを管理するために使用されるインターフェース

WIMの実装

・PowerShellによるシステム管理・Windows製品をはじめ、Linuxディストリビューションの操作・管理も可能になり、システムの更なる一元管理性の向上が期待される