Presentation is loading. Please wait.

Presentation is loading. Please wait.

MGT305 Windows PowerShell Next Generation Command Line Scripting Jeffrey Snover & Leonard Chung Windows Enterprise Management Division.

Similar presentations


Presentation on theme: "MGT305 Windows PowerShell Next Generation Command Line Scripting Jeffrey Snover & Leonard Chung Windows Enterprise Management Division."— Presentation transcript:

1 MGT305 Windows PowerShell Next Generation Command Line Scripting Jeffrey Snover & Leonard Chung Windows Enterprise Management Division

2 Keynote Reprise: Windows PowerShell has Released! Download Link Download Link www.microsoft.com/powershell www.microsoft.com/powershell www.microsoft.com/powershell Supported platforms Supported platforms Windows XP & Windows Server 2003 Windows XP & Windows Server 2003 Windows Vista version out shortly Windows Vista version out shortly Support for x86, x64, and ia64 Support for x86, x64, and ia64 Lots of Partners! Lots of Partners!

3 Microsoft Products Providing Windows PowerShell Cmdlets Windows Vista Exchange Server 2007 Operations Manager 2007 Windows Server “Longhorn” Virtual Machine Manager Data Protection Manager “V2”

4 Microsoft MVPs PowerShell Team Blog Active Newsgroup Channel 9: DFO Show IIS.net Visit www.microsoft.com/powershell for more infowww.microsoft.com/powershell TechNet ScriptCenter Exchange Server 2007 Terminal Server WMI, Registry, Hardware, etc. Community Submitted Scripts Windows PowerShell Ecosystem Partners 100s of Scripts MyITForum.com Manning Publications O’Reilly Publications Sapien Press and Other Publishers Community Support Books and Training Materials

5 Agenda Introduction Introduction What is Windows PowerShell? What is Windows PowerShell? Shell Shell Why is Windows PowerShell a great interactive shell? Why is Windows PowerShell a great interactive shell? Scripting Scripting How can I script with Windows PowerShell? How can I script with Windows PowerShell?

6 Windows PowerShell Next generation command line shell that is: Next generation command line shell that is: As interactive and composable as BASH/KSH As interactive and composable as BASH/KSH As programmatic as Perl/Ruby As programmatic as Perl/Ruby As production oriented as AS400 CL/VMS DCL As production oriented as AS400 CL/VMS DCL Allows access to data stores as easy to access as filesystems Allows access to data stores as easy to access as filesystems

7 Admin Tools Roadmap ScenarioTodayTomorrow PowerShell Benefits GUI Shell MMC MMC with snap-ins layered on PowerShell GUI-Cmd parity GUI-Cmd parity Auto script creation (V2) Auto script creation (V2) Command Shell CMDCMDPowerShell CMD and UNIX shell parity CMD and UNIX shell parity Command consistency Command consistency Namespaces as Drives (e.g. FS, Reg, WMI, AD, Certs, etc) Namespaces as Drives (e.g. FS, Reg, WMI, AD, Certs, etc) Command Scripting CMD scripting PowerShell Richer language Richer language Better text utilities Better text utilities COM Scripting WSH VBScript VBScript Jscript JscriptWSH VBScript VBScript Jscript Jscript Jscript (.net) PowerShell Richer language Richer language Object utilities Object utilities Common access to COM, XML,.NET, ADO, WMI, ADSI Common access to COM, XML,.NET, ADO, WMI, ADSI

8 Try things out in an interactive shell Try things out in an interactive shell Stitch things together with utilities Stitch things together with utilities Put the results in a script file Put the results in a script file Realize that the tools are unsuitable and restart with a new set of tools Realize that the tools are unsuitable and restart with a new set of tools Generalize (e.g., parameterize) Generalize (e.g., parameterize) Clean it up  production-quality Clean it up  production-quality Integrate into your environment Integrate into your environment Share with the community Share with the community Admin Development Model

9 The 4 Pillars of Discoverability 1. Get-Command 2. Get-Help and -? 3. Get-PSDrive 4. Get-Members

10 Once around the track Leonard Chung PowerShell Program Manager Windows Enterprise Management Division

11 Clear, Concise, Consistent, Learnable Get-Process | Where { $_.handles –gt 500 } | Sort handles | Format-Table Get-Process Cmdlet Common Windows PowerShell Parser Windows PowerShell Pipeline Processor Where Cmdlet Sort Cmdlet Format Cmdlet

12 Extending PowerShell with PowerGadgets Rene Garcia President PowerGadgets

13 How can I script with Windows PowerShell? Script against various: Script against various: Instrumentation: Text, COM,.NET, Cmdlets Instrumentation: Text, COM,.NET, Cmdlets Object types: WMI, XML, ADO, ADSI Object types: WMI, XML, ADO, ADSI Datastores: Filesystem, Registry, Certs, etc Datastores: Filesystem, Registry, Certs, etc Ad-hoc scripts need to be quick and easy Ad-hoc scripts need to be quick and easy Arguments don’t need to be named or typed Arguments don’t need to be named or typed Scripts don’t need to be signed Scripts don’t need to be signed Production scripts need be to production quality Production scripts need be to production quality Arguments can be typed, named and have initializers Arguments can be typed, named and have initializers Rich error handling Rich error handling Protection from uninitialized variables Protection from uninitialized variables Data can be written to multiple streams Data can be written to multiple streams Output, Error, Debug, Verbose, Warning, Progress Output, Error, Debug, Verbose, Warning, Progress Scripts can be digitally signed Scripts can be digitally signed

14 Simple Scripting Arguments not declared or typed Arguments not declared or typed function MyEcho { for ($i = 0; $i –lt $args.count; $i++) for ($i = 0; $i –lt $args.count; $i++) { “arg{0} = {1}” –f $i, $args[$i] “arg{0} = {1}” –f $i, $args[$i] }}

15 Advanced Scripting function Get-Total ( [String]$property = $(throw "Property Required"), [string]$formatString = "Total {1} = {0}" ) { Begin { $total = 0 { $total = 0 } Process Process { $total += $_.$property { $total += $_.$property } End End { $formatString -f $total,$property { $formatString -f $total,$property }} Arguments declared, typed, initialized

16 Sophisticated Scripting function Get-Types ( [ScriptBlock]$AssemblyFilter = {1}, [ScriptBlock]$TypeFilter = {$_.IsPublic –eq “TRUE”} ){ TRAP [System.Exception] {Write-Error “ERROR: $_.Exception”} TRAP [System.Exception] {Write-Error “ERROR: $_.Exception”} foreach ($a in [AppDomain]::CurrentDomain.GetAssemblies() | where $AssemblyFilter) { $a.GetTypes() | where $TypeFilter }} Uses.NET APIs, traps, ScriptBlocksUses.NET APIs, traps, ScriptBlocks

17 IDE Development Model PrimalScript Don Jones Sapien Technologies Inc www.Sapien.com

18 MySpace Dan Farino Chief Systems Architect MySpace.com

19 More Windows PowerShell Sessions PowerShell Scripting in Exchange Server 2007 (UCMCT05) PowerShell Scripting in Exchange Server 2007 (UCMCT05) Solving Management Problems with Windows PowerShell (MGT314) Solving Management Problems with Windows PowerShell (MGT314) Exploring Windows PowerShell Utilities (MGTCT08) Exploring Windows PowerShell Utilities (MGTCT08) Windows PowerShell Lightning Tour (MGTLD03) Windows PowerShell Lightning Tour (MGTLD03)

20 Ask The Experts Get Your Questions Answered You can find us at the Microsoft Ask the Experts area, located in the Exhibition Hall: Wednesday15 November10.15 – 10.45 Thursday16 November10.15 – 10.45 Thursday16 November14.45 – 15.45

21

22

23 Useful Resources Newsgroup: Microsoft.Public.Windows.PowerShell Channel 9 tag: http://channel9.msdn.com/tags/Monad http://channel9.msdn.com/tags/Monad Team blog: http://blogs.msdn.com/PowerShell/ http://blogs.msdn.com/PowerShell/ Script Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx Books: O’Reilly: http://www.oreilly.com/catalog/msh/ http://www.oreilly.com/catalog/msh/ Manning Press: http://manning.com/powershell/ http://manning.com/powershell/ Sapien Press: http://www.sapienpress.com/ http://www.sapienpress.com/ MshAnalyzer tool http://www.karlprosser.com/coder/?cat=8

24 Community Resources Newsgroup: Microsoft.Public.Windows.PowerShell Channel 9 tag: http://channel9.msdn.com/tags/Monad http://channel9.msdn.com/tags/Monad Team blog: http://blogs.msdn.com/PowerShell/ http://blogs.msdn.com/PowerShell/ Marc van Orsouw’s blog: http://mow001.blogspot.com http://mow001.blogspot.com Wiki: http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki Script Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx O’Reilly book – Monad: Introducing the MSH Command Shell and Language http://www.oreilly.com/catalog/msh/ Manning Press book by Bruce Payette: PowerShell in Action http://manning.com/powershell/ Sapien Press book by Don Jones: PowerShell http://www.sapienpress.com/ MshAnalyzer tool http://www.karlprosser.com/coder/?cat=8

25 Resources Technical Chats and Webcasts http://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/usa/webcasts/default.asp Microsoft Learning and Certification http://www.microsoft.com/learning/default.mspx MSDN & TechNet http://microsoft.com/msdn http://microsoft.com/technet Virtual Labs http://www.microsoft.com/technet/traincert/virtuallab/rms.mspx Newsgroups http://communities2.microsoft.com/ communities/newsgroups/en-us/default.aspx Technical Community Sites http://www.microsoft.com/communities/default.mspx User Groups http://www.microsoft.com/communities/usergroups/default.mspx

26 ©2006 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


Download ppt "MGT305 Windows PowerShell Next Generation Command Line Scripting Jeffrey Snover & Leonard Chung Windows Enterprise Management Division."

Similar presentations


Ads by Google