1 / 27

Advanced Automation Using Windows PowerShell 2.0

Required Slide. SESSION CODE: WSV401. Advanced Automation Using Windows PowerShell 2.0. Mir Rosenberg & Refaat Issa Program Managers Microsoft Corporation. Objectives and Takeaways. Demonstrate the advanced features of Windows PowerShell scripting for automating your IT environment

Download Presentation

Advanced Automation Using Windows PowerShell 2.0

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.


Presentation Transcript

  1. Required Slide SESSION CODE: WSV401 Advanced Automation Using Windows PowerShell 2.0 Mir Rosenberg & Refaat Issa Program Managers Microsoft Corporation

  2. Objectives and Takeaways • Demonstrate the advanced features of Windows PowerShell scripting for automating your IT environment • Key Takeaways – How To: • Write functions and advanced functions • Make your scripts world-ready • Easily create graphical applications over PowerShell • Incorporate exception handling • Use the Debugger to debug your script or function • Package your functions into modules

  3. FUNCTIONS • Reusable and discoverable • Support for parameters: • Parameter list • Param statement • $args • Parameter initialization • Support for pipeline processing through code blocks: • Begin • Process • End • Missing: Help, parameter sets, validation …

  4. Functions Refaat IssaProgram ManagerMicrosoft Corporation DEMO

  5. ADVANCED FUNCTIONSScriptCmdlets • Cmdlet behavior • Parameter binding • Parameter sets and default parameter set • Support for parameter attributes: metadata & validation • Support for ubiquitous parameters • –whatif • –confirm • –verbose • –debug • Inline and external help

  6. Advanced Functions Refaat IssaProgram ManagerMicrosoft Corporation DEMO

  7. Script Internationalization • Let’s take over the world! • Localize your scripts into any language supported by Windows • Scripts  .ps1 files • Resources  .psd1 files • If Windows can display it, you can use it! • Cmdlets • Import-LocalizedData • ConvertFrom-StringData

  8. Script Internationalization Mir RosenbergProgram ManagerMicrosoft Corporation DEMO

  9. GUI Over PowerShell • Best practice: Build GUI over PowerShell cmdlets • Easy to build • Easy to change • GUI -le CLI • Choose your own GUI adventure! • Lower the barrier to entry: more users can run automated management tasks

  10. GUI Over PowerShell Mir RosenbergProgram ManagerMicrosoft Corporation DEMO

  11. Debugging • Command-line debugger • Graphical debugger • Set breakpoints: • Line • Variable • Command • Step over, in, out – or specify an action • Hover over variables to see their value, or use the command-line

  12. Debugging Refaat IssaProgram ManagerMicrosoft Corporation DEMO

  13. Exception Handling • V1 had trap • V2 introduced: try{}catch{}finally{} • Put code that can throw an exception in a try block • Have zero or more catch blocks • From most specific to most general exceptions • Put must-execute cleanup code in a finally block

  14. Exception Handling Refaat IssaProgram ManagerMicrosoft Corporation DEMO

  15. Modules • Replace snap-ins • Exceptions: v1 support needed • Enable users to organize PowerShell code into reusable, self-contained units • Provide an isolated execution environment • Ability to repackage and abstract other modules to create custom solutions • Attach metadata to describe module functionality and control loading behavior

  16. Modules Mir RosenbergProgram ManagerMicrosoft Corporation DEMO

  17. Windows PowerShell Community Resources • Team blog: http://blogs.msdn.com/PowerShell • PowerShell Community: http://www.powershellcommunity.org • Newsgroup: Microsoft.Public.Windows.PowerShell • PowerShell Forum: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads • Channel 9: http://channel9.msdn.com/tags/PowerShell • Wiki: http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki • Script Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx • CodePlex: http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershell • Some good books • PowerShell in Action by Bruce Payette http://manning.com/powershell • Windows PowerShell Cookbook by Lee Holmes http://www.oreilly.com/catalog/9780596528492/index.html • Professional Windows PowerShell Programming http://www.wrox.com/WileyCDA/WroxTitle/productCd-0470173939.html

  18. PowerShellCommunity.org • www.PoshComm.org • Free, independent, and open community • Dedicated to the enhancement and enrichment of PowerShell • Increase the awareness and usage of PowerShell • Forums • User group support

  19. Required Slide Speakers, please list the Breakout Sessions, Interactive Sessions, Labs and Demo Stations that are related to your session. Related Content • Breakout Sessions • WSV334 - Windows Server 2008 R2: Tips on Automating and Managing the Breadth of Your IT Environment • WSV401- Advanced Automation using Windows PowerShell 2.0 • WCL308 -Inventory Your Network and Clients with Windows PowerShell • DAT311 -Microsoft SQL Server Management: Reduce TCO Using Policy-Based Management and Windows PowerShell • OSP402 - Windows PowerShell Made Less Scary for the Microsoft SharePoint Server 2010 Administrator • SIA306 - Night of the Living Directory: Understanding the Windows Server 2008 R2 Active Directory… • WSV319 - Manage Your Enterprise from a Single Seat: Windows PowerShell Remoting • WCL313 - Paradigm Shift: Microsoft Visual Basic Scripting Edition to Windows PowerShell • Interactive Sessions • WCL06-INT - Using Windows PowerShell for Enterprise Desktop Automation • WSV09-INT - Server Deployment and Maintenance in Windows Server 2008 R2 • Hands-on Labs • WSV18-HOL - Introduction to Windows PowerShell Fundamentals • WSV19-HOL - Advanced Windows PowerShell Scripting • Product Demo Stations • TLC-WSV8-Orange - Windows PowerShell and Server Management

  20. Required Slide Resources Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet • http://microsoft.com/msdn

  21. Required Slide Complete an evaluation on CommNet and enter to win!

  22. Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st http://northamerica.msteched.com/registration You can also register at the North America 2011 kiosk located at registrationJoin us in Atlanta next year

  23. © 2010 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. PowerShell’s Value Proposition • Automation is a core challenge for our IT Pros. • PowerShell provides a consistent mechanism across management applications to automate administration tasks • Allows experienced admins to automate tasks which can be run by less-experienced admins • Reduces the dependency on developers writing IT solutions  less disconnect & less wait

  25. CMDLETS – A quick refresher • Compiled commands • Discoverable • Consistent naming & syntax • Aliases • Ubiquitous parameters: • -whatif, -confirm, -error, -errorAction, -debug • Parameter sets • Rich help • Formatting

  26. ONE-LINERSAutomating the world … one-liner at a time • Cmdlets emit real objects • The pipeline • $_ • ForEach-Object and Where-Object • Interactive, experimental • Useful, often-used one-liners should be turned into functions

  27. Required Slide

More Related