1 / 26

MGT305 Windows PowerShell Next Generation Command Line Scripting

MGT305 Windows PowerShell Next Generation Command Line Scripting. Jeffrey Snover & Leonard Chung Windows Enterprise Management Division. Keynote Reprise: Windows PowerShell has Released!. Download Link www.microsoft.com/powershell Supported platforms Windows XP & Windows Server 2003

abra
Télécharger la présentation

MGT305 Windows PowerShell Next Generation Command Line Scripting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

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

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

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

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

  7. Admin Tools Roadmap

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

  9. The 4 Pillars of Discoverability Get-Command Get-Help and -? Get-PSDrive 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 Common Windows PowerShell Parser Get-ProcessCmdlet Sort Cmdlet FormatCmdlet Where Cmdlet Windows PowerShell Pipeline Processor

  12. Extending PowerShell with PowerGadgets Rene Garcia President PowerGadgets

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

  14. Simple Scripting Arguments not declared or typed function MyEcho { for ($i = 0; $i –lt $args.count; $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 } Process { $total += $_.$property } End { $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”} foreach ($a in [AppDomain]::CurrentDomain.GetAssemblies() | where $AssemblyFilter) { $a.GetTypes() | where $TypeFilter } } • Uses .NET APIs, traps, ScriptBlocks

  17. IDE Development ModelPrimalScript 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) • Solving Management Problems with Windows PowerShell (MGT314) • Exploring Windows PowerShell Utilities (MGTCT08) • Windows PowerShell Lightning Tour (MGTLD03)

  20. Ask The ExpertsGet Your Questions Answered You can find us at the Microsoft Ask the Experts area, located in the Exhibition Hall: Wednesday 15 November 10.15 – 10.45 Thursday 16 November 10.15 – 10.45 Thursday 16 November 14.45 – 15.45

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

  22. Community Resources Newsgroup: Microsoft.Public.Windows.PowerShell Channel 9 tag: http://channel9.msdn.com/tags/Monad Team blog: http://blogs.msdn.com/PowerShell/ Marc van Orsouw’s blog: 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

  23. Resources

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

More Related