Pro Windows PowerShell

Book description

Windows power users have always envied their friends running UNIX machines for the ease of automation that they enjoy. The traditional Windows command-line shell, cmd.exe, has never been up to par with shells like bash or tcsh, especially when it comes to text processing and process automation.

Windows PowerShell changes all that. This next-generation shell is also a full-blown scripting environment with a real programming language that allows users to access every part of their operating system. Files, registry entries, and COM and .NET objects are all supported by PowerShell, which makes manipulating them a breeze.

Pro Windows PowerShell will show you how to use all this power in your own work. You'll discover the object-oriented features of the shell and how they help in extracting and manipulating data. You'll then learn how to use those features to solve real-world problems: manipulating files, working with text, monitoring systems, and performing operations over the network. The book serves as not only a tutorial, but also a reference: the "Real World" part is structured so that it can be read nonlinearly and used as a reference or a cookbook. And you'll find freely available tools and extensions that will help you do things even faster.

Pro Windows PowerShell is your best companion to the capabilities and power that PowerShell offers you.

Table of contents

  1. Copyright
  2. Dedication
  3. About the Author
  4. About the Technical Reviewer
  5. Acknowledgments
  6. Introduction
    1. Why Another Book on Windows PowerShell?
    2. What's in This Book?
    3. Do I Need Prior Programming Experience?
  7. Objects and Object Types
    1. The Extended Type System
    2. Built-in Types
    3. Type Literals
    4. Summary
  8. Controlling Execution Flow
    1. Conditional Expressions
    2. Branching Instructions
    3. Loops: Repeatedly Executing Blocks of Code
    4. Summary
  9. The Object Pipeline
    1. Text-Based Pipelines
    2. Object-Based Pipelines
    3. Processing Collections Using ForEach-Object
    4. Filtering Collections Using Where-Object
    5. Adding or Deleting Properties Using Select-Object
    6. Sorting Collections
    7. Pipeline Tees
    8. Grouping Objects
    9. Gathering Collection Statistics
    10. Detecting Changes and Differences Among Objects
    11. The Object Pipeline and Functional Programming
    12. Summary
  10. Working with Script Blocks
    1. Defining Script Blocks
    2. Passing Parameters and Returning Values
    3. Processing Pipeline Input
    4. Invoking Strings as Expressions
    5. Script Blocks as Delegates
    6. Summary
  11. Working with Functions
    1. Defining Functions
    2. Filters
    3. Functions and Script Blocks
    4. Summary
  12. Command Aliases
    1. Working with Aliases
    2. Aliasing Tips, Techniques, and Pitfalls
    3. Built-in Aliases
    4. Summary
  13. Providers
    1. Enumerating Providers
    2. Drives
    3. Navigating to Drives
    4. Provider Capabilities
    5. Summary
  14. Script Files
    1. Creating Scripts
    2. Executing PowerShell Scripts from Other Environments
    3. Developing and Maintaining Script Libraries
    4. Summary
  15. Error Handling and Debugging
    1. Handling Errors
    2. Debugging Your Code
    3. Summary
  16. Signing Scripts
    1. How Code Signing Works
    2. Managing Certificates
    3. Creating a Self-Signed Certificate
    4. Signing Scripts
    5. Running Scripts on Other Machines
    6. Summary
  17. The Shell Environment and Its Configuration
    1. Shell Hosts
    2. User Profile Scripts
    3. Working with Saved Console Settings
    4. Changing the Prompt Settings
    5. Tab Expansion: How Command Completion Works
    6. Summary
  18. Extending the Type System
    1. Modifying Objects and Types
    2. Extending Object Formatting
    3. Summary
  19. Getting Help
    1. The Help System
    2. Getting Command Information
    3. Getting Information About Objects
    4. Using the Internet to Get Help
    5. Summary
  20. Taming Processes and Services
    1. Working with Processes
    2. Administering Services
    3. Summary
  21. Input and Output
    1. Reading Content
    2. Writing Content
    3. Content Encoding
    4. Getting Byte Content
    5. Extracting Data from Text
    6. Summary
  22. Monitoring Your System
    1. Working with the Windows Event Log
    2. Performance Counters
    3. Summary
  23. PowerShell and the World Wide Web
    1. Laying the Foundation
    2. Testing and Validating Web Sites
    3. Working with News Feeds
    4. Calling Web Services
    5. Handling FTP Transactions
    6. Summary
  24. Sending E-mail
    1. Using System.Net.Mail
    2. Building a Reusable Script
    3. Configuring Recipients
    4. Working with Message Headers
    5. Multipart Messages
    6. Putting It All Together
    7. Summary
  25. Talking to COM Objects
    1. How COM Works
    2. How PowerShell Supports COM
    3. Scripting Programs Through Their COM Interfaces
    4. Windows Script Host Code Interoperability
    5. Summary
  26. Managing Windows with WMI
    1. A Brief History of WMI
    2. WBEM and WMI Components
    3. PowerShell's WMI Support
    4. Language Support for WMI Objects
    5. Exploring CIM Classes and Objects
    6. Querying Hardware Devices
    7. Getting Information About Software
    8. The Network Configuration
    9. Generating WMI Code
    10. Summary
  27. PowerShell Community Extensions
    1. Installation and Configuration
    2. File System Utilities
    3. Network Utilities
    4. Executing Processes and Commands
    5. XML Tools
    6. Working with Image Files
    7. Clipboard Helpers
    8. New Providers
    9. Utility Applications
    10. Summary
  28. PSEventing: .NET Events in PowerShell
    1. Introducing PSEventing
    2. Event-Handling Mechanics
    3. FileSystemWatcher: A Real-World Example
    4. Monitoring Entries Written to the System Event Logs
    5. Handling WMI Events
    6. Detecting If Our Script Has Been Terminated by the User
    7. Using Script Blocks As Event Handlers
    8. Summary
  29. Enhancing Tab Completion with PowerTab
    1. Installation
    2. How PowerTab Works
    3. Configuring PowerTab
    4. Summary

Product information

  • Title: Pro Windows PowerShell
  • Author(s): Hristo Deshev
  • Release date: February 2008
  • Publisher(s): Apress
  • ISBN: 9781590599402