windows powershell 5.0 と windows server vnext の管理
Post on 13-Jul-2015
837 Views
Preview:
TRANSCRIPT
Windows PowerShell 5.0 とWindows Server vNextの管理System Center User Group Japan 第11回勉強会 (2014.12.13)
高井一輝
はじめに
本日のセッションスライドは SlideShareで公開しています
2
自己紹介
高井一輝 (Takai Kazuki)
某ISP勤務
クラウドとオンプレミスを組み合わせたインテグレーション
クラウドサービスの開発、設計、設備維持
Windows Server / System Center / Linux / etc…
System Center User Group Japan (SCUGJ)
Twitter : @zhuky7 / Facebook : kazuki.takai
Blog : http://operationslab.wordpress.com/
3
本日の内容とゴール
内容
PowerShell 5.0 の紹介
WMF 5.0 / PowerShell 5.0 Preview の新機能紹介
Demoを中心に
セッションのゴール
PowerShell 5.0 の新機能 / vNextで標準搭載される機能が何となく分かる
PowerShell 5.0 の検証を始めてみる(始めたくなる / 始められる)
4
はじめる前に
このセッションでは Preview 版の製品、テクノロジーについて記載しています
2014/12 時点の情報をベースにしています
今後のリリースで機能や動作が変更、削除される可能性があります
主に、Windows PowerShell 5.0 について記載します
Windows Server vNextの新機能に紐づく個々のコマンドレットについては(ほとんど)記載しません
5
本日の環境
Windows Server 2012 R2 on Microsoft Azure
with Windows Management Framework 5.0 Preview November 2014
Windows Server vNext (Technical Preview) on Windows Azure
Get-ExecutionPolicy ## (Default: RemoteSigned)
Enable-PSRemoting -Force
Set-Item WSMan:¥localhost¥Client¥TrustedHosts -Value *
## (Network Profile) Private Network
6
Pre-configuration
7
(改めて)PowerShellとは
Windows で利用可能な新しい標準のシェル / スクリプト言語
Windows Server 2008 R2 以降で標準搭載
コマンドプロンプトよりも高度な処理 / 制御が可能
WSH よりもスクリプトの記述が容易
Character-based User Interface
テキストベースではなくオブジェクトベース
パイプラインを流れるのはオブジェクト
豊富なコマンドレット
8
PowerShell のメリット
Windows 標準で利用可能
GUIより詳細な設定が可能
スクリプトを利用することで、効率化/自動化が可能
9
Windows Server と PowerShell
Windows Server の進化とともに、PowerShell も進化
PowerShell 1.0 : Windows Server 2003, Windows XP, Vista の追加コンポーネント
PowerShell 2.0 : Windows Server 2008 R2 に標準搭載 (2003 – 2008 対応)
PowerShell 3.0 : Windows Server 2012 に標準搭載 (2008, 2008 R2 対応)
PowerShell 4.0 : Windows Server 2012 R2 に標準搭載 (2008 R2, 2012対応)
PowerShell 5.0 : Windows Server vNextに標準搭載予定
10
Windows Server vNextの PowerShell
PowerShell 5.0
Windows Management Framework 5.0
デフォルトでインストール、有効化
11
2012 R2 vs vNext
12
WMF 5.0 Preview November 2014
2014/12/10 現在、以下の OSに対応
Windows 8.1
Windows Server 2012 R2
Windows Server 2012
KB3006193 をインストールすることで利用可能
Windows Server 2012 の場合は、KB2894867
以下の環境にはインストールしないこと
System Center 2012 Configuration Manager (not including SP1)
Windows Small Business Server 2011 Standard
13
PowerShell 5.0 の新機能 (1/2)
OneGetを使用したソフトウェアのインストール
PowerShellGet を使用したモジュールの管理
クラスの定義
デバッグ関連の機能追加(拡充)
DSC関連の機能追加
OData エンドポイントからコマンドレットを生成
監査/ロギング機能の強化
ネットワークスイッチ管理のためのコマンドレット追加
14
Experimental
Experimental
Experimental
Experimental
Stable
Stable
Experimental
Stable
Experimental
※ 12/13 現在
PowerShell 5.0 の新機能 (2/2)
ZIPファイルの操作
シンボリックリンク関連の機能強化
文字列から構造化オブジェクトを生成
15
Stable
Experimental
Stable
※ 12/13 現在
OneGet
リポジトリベースのパッケージ管理システム(のようなもの)
コアシステム (OneGet Core)
管理用のコマンドレット (OneGet PowerShell Module)
PowerShell 上から操作・管理可能
*-Package コマンドレット群
リポジトリの追加が可能
*-PackageProvider
16
DemoDiscover and Install Software with OneGet
17
OneGet
WMF 5.0 Preview Nov 2014 においては、初めに以下コマンドレットが必要
Get-PackageProvider –Name NuGet –ForceBootstrap
追加プロバイダーの保存先
管理者として実行した場合 : $env:PROGRAMFILES¥OneGet¥ProviderAssemblies
それ以外の場合 : $env:LOCALAPPDATA¥OneGet¥ProviderAssemblies
18
PowerShellGet
PowerShell のモジュールや DSC リソースを管理するための仕組み
リポジトリからモジュールやリソースをダウンロードしてインストール
*-Module / *-DscResource コマンドレット群
リポジトリの追加や変更が可能
Register-PSRepository / Unregister-PSRepository
Get-PSRepogitory / Set-PSRepogitory
19
DemoDiscover and Install Modules with PowerShellGet
20
クラスの定義
クラス及びユーザー定義型を PowerShell 言語としてサポート
class 及び enumキーワードの追加
コンストラクタ、メソッド、プロパティなどを記述
基本的には他のオブジェクト指向言語と同様
想定用途
DSCリソースを PowerShell で記述する、など
21
DemoDevelop with Classes
22
デバッグ関連の機能追加
Break ALL [すべて中断]
操作を行った段階で(ブレークポイント外でも)実行を中断
Ctrl + Break (Console)
Ctrl + B or [Debug] Menu (ISE)
23
PowerShell 4.0 PowerShell 5.0
デバッグ関連の機能追加
リモートホストのスクリプトをデバッグ可能
PSEditコマンドがリモート対応
リモートホストに接続した状態で PSEditを実行すると、ローカル ISE 上でリモートスクリプトをオープンし編集、デバッグが可能
24
DemoRemote Debugging
25
DSC 関連の機能追加
64bit環境における 32bit プロセス環境 (WOW64) の構成をサポート
Configuration Status の集中管理 (情報の集約/レポーティング)
PowerShell ISE の DSC編集サポートの強化
インテリセンスがより賢く
DSC Local Configuration Manager 向けの Meta-Configuration Attribute
DSC Configuration の分割記述
ConfigurationRepositoryWeb 経由で外部の記述をインポート
複数コンピューター間でのリソース依存関係の記述
26
その前に
Desired State Configuration (DSC)
Windows PowerShell Desired State Configuration
サーバーの構成と管理を行うための機能
操作(構築)手順ではなく、状態を記述することでサーバーを自動構成
DSC によるサーバーの構成手順
PowerShell で構成後のサーバーの状態を定義
PowerShell コードから構成データが含まれる MOF ファイルを生成
MOF ファイルを使用してサーバーを構成
27
DSC の Configuration28
Configuration WebServerConfig{
Node web01{
WindowsFeature FTPRole{
Name = "Web-FTP-Server"Ensure = "Present"IncludeAllSubFeature = $true
}}
} WebServerConfigStart-DscConfiguration -Wait -Path .¥WebServerConfig
DSC リソース29
Archive Environment File Resources A
Group Log Package Resources B
Process Registry Role Resources C
Script Service User Resources D
Windows PowerShell Desired State Configuration
Built-In Resources Custom Resources
DSC 関連の機能追加
64bit環境における 32bit プロセス環境 (WOW64) の構成をサポート
Configuration Status の集中管理 (情報の集約/レポーティング)
PowerShell ISE の DSC編集サポートの強化
インテリセンスがより賢く
DSC Local Configuration Manager 向けの Meta-Configuration Attribute
DSC Configuration の分割記述
ConfigurationRepositoryWeb 経由で外部の記述をインポート
複数コンピューター間でのリソース依存関係の記述
30
※一部の機能は、Preview では Pull モードのみをサポート
DSC 関連の機能追加
追加のリソース
PowerShellGet などからダウンロード、インストール
Azure DSC Extension
Azure VMで DSCを利用したい場合に利用
WMF 5.0 Preview Nov 2014 対応バージョン : Azure DSC Extension 1.5
Release history for the Azure DSC Extension
http://blogs.msdn.com/b/powershell/archive/2014/11/20/release-history-for-the-azure-dsc-extension.aspx
31
DemoDesired State Configuration
32
OData Endpointからコマンドを生成
OData エンドポイントのサービス情報から、PowerShell のコマンドレットを生成
New-<EntitiyType>
Get-<EntityType>
Set-<EntityType>
Remove-<EntityType>
Invoke-<EntityType>
33
監査/ロギング機能の強化
Transcriptingの改善
ファイル名自動生成機能(保存先フォルダーのみ指定)
コマンド実行時刻の自動記録が可能
外部コマンドの出力を記録可能
Script Block のロギング
全てのスクリプトブロックをイベントログへ記録
Microsoft-Windows-PowerShell/Operational
グループポリシーで有効化
Administrative Templates -> Windows Components -> Windows PowerShell
34
※ BuildVersion 6.3.9600.17400 以降で利用可能
Script Block のロギング35
※ BuildVersion 6.3.9600.17400 以降で利用可能
DemoLogging and Auditing
36
ネットワークスイッチ管理
スイッチ管理用のコマンドレットを追加
スイッチのグローバル設定
ホスト名、バナー、etc…
VLAN 設定
L2ポート設定
NetworkSwitch モジュール
認定ロゴ取得済みの L2 スイッチが必要
37
ZIPファイルの操作
ZIP ファイルの展開と ZIP形式での圧縮が可能
Compress-Archive
Expand-Archive
38
DemoCompress / ExpandZIP Archives
39
シンボリックリンク関連の機能強化
New-Item コマンドレットの ItemTypeで SymbolicLinkを指定可能
フォルダーであれば、Junction も指定可能
Remove-Item で削除する場合は注意
SymbolicLinkや Junction を指定して Remove-Item -Force すると、中身ごと消える
リンクだけ消したい場合は cmd /c rmdirで
40
DemoCreate / Delete SymbolicLink
41
文字列からオブジェクトを生成
文字列をパースして構造化オブジェクトを生成
ある程度規則性のある文字列
アノテーション済みのデータ(サンプル)
ConvertFrom-String -TemplateFile
42
DemoExtract and ParseStructured Objects
43
その他
JEA (Just Enough Administration)
実行可能な操作やアクセス可能なオブジェクトを制限
Just-in-Time Admin Access
MIM (Microsoft Identity Manager) と連携して、必要なときのみ権限を付与
Privileged groups / TTL
PowerShell DSC for Linux
DSCリソースと Linux側の対応 (OMI) があれば PowerShell 4.0 でテスト可能
Centralized DSC Error Reporting
未実装!
44
まとめ
PowerShell 5.0 は着実に進化
ソフトウェア/モジュールのインストール簡易化
環境管理上は検討が必要
DSCの利用範囲/適用範囲が拡大
まずは利用してみる!
45
参考資料
Windows Management Framework 5.0 Preview November 2014
https://www.microsoft.com/en-us/download/details.aspx?id=44987
What‘s New in Windows PowerShell – TechNet
http://technet.microsoft.com/en-us/library/hh857339.aspx
Windows PowerShell Blog
http://blogs.msdn.com/b/powershell/
PowerShell Gallery
https://www.powershellgallery.com/
PowerShell Advent Calendar 2014
https://atnd.org/events/59220
46
ご清聴ありがとうございました
47
top related