Presentation is loading. Please wait.

Presentation is loading. Please wait.

呂政周 精誠恆逸教育訓練處 資深講師 http://edu.uuu.com.tw Windows PowerShell 呂政周 精誠恆逸教育訓練處 資深講師 http://edu.uuu.com.tw.

Similar presentations


Presentation on theme: "呂政周 精誠恆逸教育訓練處 資深講師 http://edu.uuu.com.tw Windows PowerShell 呂政周 精誠恆逸教育訓練處 資深講師 http://edu.uuu.com.tw."— Presentation transcript:

1 呂政周 精誠恆逸教育訓練處 資深講師 http://edu.uuu.com.tw
Windows PowerShell 呂政周 精誠恆逸教育訓練處 資深講師

2 課程大綱 Windows PowerShell 簡介 Windows PowerShell 的優點
使用Windows PowerShell Cmdlets Windows PowerShell Provider 使用 PowerShell Script 使用 WMI 使用 Active Directory 使用檔案系統 使用 Registry 管理 Exchange 2007

3 Windows PowerShell 簡介 Windows PowerShell 是微軟新創的命令列「殼層」和 script 語言
簡單、易學、易用 語法和結構通常比較簡單 開發者可快速完成程式編寫工作 直譯式的執行方式, 不需編譯

4 Windows PowerShell 的優點
以 .NET 技術為基礎,並且與現有的 WSH 保持回溯相容 可存取 .NET CLR,也可使用現有的 COM 技術 提供超過 130 種的命令列工具 (稱為 "cmdlet"),用來執行一般系統管理工作 管理服務、處理序、事件記錄檔、憑證、登錄,以及使用WMI 等 支援現有的指令碼語言和現有的命令列工具,以及多個 Windows 版本 Windows XP、Windows Server 2003、Windows Vista 以及 Windows Server 2008

5 Windows PowerShell 的優點 (續)
在命令列剖析複雜的運算式及操作 .NET Framework 物件 包括以管道輸送物件,協助 IT 專業人員更有效率的工作 管理不同存放區和不同格式的 Windows 資料 ADSI、WMI、COM 物件、ADO、HTML 和 XML 的標準公用程式 可擴充的介面,讓獨立軟體廠商和企業開發人員建立自訂的 cmdlet,符合應用程式和系統管理的獨特需求。

6 Windows PowerShell Overview
Command-Line Interface Task Automation Exchange Snap-In Bulk Operations Extends Console

7 下載 PowerShell Windows Server 2008是第一個內建Windows PowerShell 的Windows系統
預設並未安裝 Windows 其他系統亦可下載安裝 Windows Vista x Windows Vista x Windows XP Service Pack 2 x Windows Server 2003 Service Pack 1 x

8 安裝 PowerShell 執行PowerShell需要Microsoft .NET v2.0.50727版以上的環境
Windows Vista、Windows Server 2008已內建符合要求 .NET 執行環境 Windows Server 2003 SP1 或 Windows XP SP2 就需要自行下載安裝 .NET 執行環境 Microsoft .NET Microsoft .NET 安裝後,可以在『開始』功能表看到『Windows PowerShell』資料夾,裡面有執行MSH的捷徑。只要執行MSH的捷徑,就可以開啟MSH的執行環境。

9 使用PowerShell PowerShell 的第一次接觸

10 Windows PowerShell 可以視為 Cmd 命令提示字元的延伸,許多 Cmd 或指令都可以繼續在 Windows PowerShell 執行,而且大部分的命令列工具程式也都能繼續在 Windows PowerShell 使用;例如 cd/chdir、dir、cls、ls、 ipconfig或是ServerManagerCmd …等. Windows PowerShell 不分字母大小寫,因此 dir 和 Dir 都會視為相同的指令。

11 Cmdlet Windows PowerShell 雖然內建了若干指令,但重要及有用的功能是來自於外加的工具程式。例如Cmd 雖然內建了若干指令(例如 dir、cls 等),但如果無法執行外加的工具程式(例如 IPConfig、Net、NetSH、ServerManagerCmd 等等),Cmd 就失去價值及擴充的能力了。Windows PowerShell 也是如此。 Windows PowerShell 有自己的工具程式規格,而 Windows PowerShell 的工具程式稱為 cmdlet。

12 Cmdlet 特性 名稱是由兩個部分所組成,並以橫線連結這兩個部分:前為動作、後為動作的標的
例如 Get-Help 能取得線上說明 Get-Process 能取得行程資訊 PowerShell 1.0 提供了 129 個 cmdlet 提供了一個可列出所有 cmdlet 的 cmdlet Get-Command 這個 cmdlet 會列出所有 cmdlet 的指令類型(都是 Cmdlet)、名稱,以及節錄的語法說明.

13 Get-Help 如果想要知道某個 cmdlet 的使用說明,利用 Get-Help cmdlet 或以下 3 種方法,都可以達到相同的目的

14 Get-Help (續) Get-Help (或 Help) 還可以透過萬用字元列出相關主題 Get-Help * →列出所有說明主題
Get-Help set-* →列出所有 set- 開頭的主題 Get-Help *object* →列出所有名稱裡有 object 的主題 Get-Help about* →列出所有概念主題 Get-Help about_redirection →列出『重新導向』概 念主題的說明內容

15 Get-Help (續) 有些主題或 cmdlet 還可以利用 Get-Help/Help 的 -detailed 或 -full 參數,列出包含範例的詳細或所有說明,而 -examples 參數則可以列出範例;例如: Get-Help Get-Help -detailed →列出 Get-Help 的詳細說明 Help dir -full →列出 dir 的完整說明 Help dir -examples →僅列出 dir 的範例

16 指令的參數與用法 除了 cmdlet,Windows PowerShell 的指令還包括別名、函式、程式、script 檔案
輸入指令的同時,有時候必須輸入適當的參數。不同類型的指令,其參數的格式亦略有差異。 對 Cmdlet 及別名來說,有些參數包含成對的參數名稱及參數值,有些參數則只有參數名稱或參數值,而參數名稱是以短橫線作為前置符號;例如以下的 -name dir 就是成對的參數名稱(-name)和參數值(dir),-examples 則沒有參數值: Get-Help -name dir -examples

17 指令的參數與用法 (續) 指令的參數分成必要參數和可以省略的選用參數兩類,查詢指令用法的說明會以一對半形的方括號括住選用參數,必要參數則不會有符號括住;以方括號括住表示可以省略。例如 Get-Help 的用法: Get-Help [[-name] <string>] [-component <string[]>] [-functionality <string[]>] [-role <string[]>] [-category <string[]>] [-examples] [<CommonParameters>] 查詢指令的用法時,經常會看到以上用法說明,其中:

18 指令的參數與用法 (續) 指令的參數分成必要參數和可以省略的選用參數兩類,查詢指令用法的說明會以一對半形的方括號括住選用參數,必要參數則不會有符號括住;以方括號括住表示可以省略。例如 Get-Help 的用法: Get-Help [[-name] <string>] [-component <string[]>] [-functionality <string[]>] [-role <string[]>] [-category <string[]>] [-examples] [<CommonParameters>]

19 指令的參數與用法 (續) 查詢指令的用法時,經常會看到以上用法說明,其中: 一共有 7 個選用參數,並沒有必要參數。
前 5 個參數包含了成對的參數名稱和參數值。 [<CommonParameters>] 參數只有參數值;這個參數意指每個 cmdlet 都支援的共同參數。 第 1 個參數的參數名稱也以方括號括住,表示這個參數名稱可以省略,所以我們可以只輸入 Get-Help dir。 •第 1 個參數的參數值是 <string>,表示這個參數值為字串;以角括號括住,表示必須輸入適當的參數值,而不是輸入 string。

20 指令的參數與用法 (續) 以實例來說明參數名稱的簡略輸入法則,例如以下的指令: Get-Help -name dir –examples
上述指令經過 cmdlet 的參數名稱簡略輸入法則可以變成: Get-Help -n dir –ex Get-Help -nam dir -exa

21 Object Pipelines in Action
4/15/2019 7:07 PM Object Pipelines in Action gps|where{$_.handles -gt 500}|sort handles|ft name,handles Windows PowerShell engine gps | where{$_.handles -gt 500} | sort handles | ft name,handles gps (Get-Process) where (Where-Object) sort (Sort-Object) ft (Format-Table) (Out-Host) Operating system platform © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

22 演練

23 4/15/2019 7:07 PM 結論 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

24 Community Resources Newsgroup Channel 9 tag Team blog Wiki
4/15/2019 7:07 PM Community Resources Newsgroup Microsoft.Public.Windows.PowerShell Channel 9 tag Team blog Wiki Script Center Lots of community blogs (e.g.) Windows PowerShell Analyzer tool © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

25 For More Information Visit TechNet at: Windows PowerShell: Books:
4/15/2019 7:07 PM For More Information Visit TechNet at: Windows PowerShell: Books: Windows PowerShell in Action by Bruce Payette (Manning Publications, 2007) Microsoft Windows PowerShell: TFM by Don Jones and Jeffery Hicks (SAPIEN Press, 2007) Windows PowerShell Step by Step by Ed Wilson (Microsoft Press®, 2007) Monad (AKA PowerShell): Introducing the MSH Command Shell and Language by Andy Oakley (O'Reilly Media, Inc., 2005) © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

26 © 2007 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "呂政周 精誠恆逸教育訓練處 資深講師 http://edu.uuu.com.tw Windows PowerShell 呂政周 精誠恆逸教育訓練處 資深講師 http://edu.uuu.com.tw."

Similar presentations


Ads by Google