Books & Videos

Table of Contents

  1. Tour

    1. A Guided Tour of Windows PowerShell

      1. Introduction
      2. An Interactive Shell
      3. Structured Commands (Cmdlets)
      4. Deep Integration of Objects
      5. Administrators as First-Class Users
      6. Composable Commands
      7. Techniques to Protect You from Yourself
      8. Common Discovery Commands
      9. Ubiquitous Scripting
      10. Ad Hoc Development
      11. Bridging Technologies
      12. Namespace Navigation Through Providers
      13. Much, Much More
  2. Fundamentals

    1. Chapter 1 The Windows PowerShell Interactive Shell

      1. Introduction
      2. Run Programs, Scripts, and Existing Tools
      3. Resolve Errors Calling Native Executables
      4. Run a PowerShell Command
      5. Invoke a Long-Running or Background Command
      6. Notify Yourself of Job Completion
      7. Customize Your Shell, Profile, and Prompt
      8. Find a Command to Accomplish a Task
      9. Get Help on a Command
      10. Program: Search Help for Text
      11. Program: View PowerShell’s HTML Help
      12. Launch PowerShell at a Specific Location
      13. Invoke a PowerShell Command or Script from Outside PowerShell
      14. Customize the Shell to Improve Your Productivity
      15. Program: Learn Aliases for Common Commands
      16. Program: Learn Aliases for Common Parameters
      17. Access and Manage Your Console History
      18. Program: Create Scripts from Session History
      19. Invoke a Command from Your Session History
      20. Program: Search Formatted Output for a Pattern
      21. Interactively View and Process Command Output
      22. Store the Output of a Command into a File
      23. Add Information to the End of a File
      24. Record a Transcript of Your Shell Session
      25. Extend Your Shell with Additional Commands
      26. Use Commands from Customized Shells
      27. Save State Between Sessions
    2. Chapter 2 Pipelines

      1. Introduction
      2. Filter Items in a List or Command Output
      3. Group and Pivot Data by Name
      4. Program: Simplify Most Where-Object Filters
      5. Program: Interactively Filter Lists of Objects
      6. Work with Each Item in a List or Command Output
      7. Automate Data-Intensive Tasks
      8. Program: Simplify Most Foreach-Object Pipelines
      9. Intercept Stages of the Pipeline
      10. Automatically Capture Pipeline Output
      11. Capture and Redirect Binary Process Output
    3. Chapter 3 Variables and Objects

      1. Introduction
      2. Display the Properties of an Item as a List
      3. Display the Properties of an Item as a Table
      4. Store Information in Variables
      5. Access Environment Variables
      6. Program: Retain Changes to Environment Variables Set by a Batch File
      7. Control Access and Scope of Variables and Other Items
      8. Program: Create a Dynamic Variable
      9. Work with .NET Objects
      10. Create an Instance of a .NET Object
      11. Program: Create Instances of Generic Objects
      12. Reduce Typing for Long Class Names
      13. Use a COM Object
      14. Learn About Types and Objects
      15. Get Detailed Documentation About Types and Objects
      16. Add Custom Methods and Properties to Objects
      17. Create and Initialize Custom Objects
      18. Add Custom Methods and Properties to Types
    4. Chapter 4 Looping and Flow Control

      1. Introduction
      2. Make Decisions with Comparison and Logical Operators
      3. Adjust Script Flow Using Conditional Statements
      4. Manage Large Conditional Statements with Switches
      5. Repeat Operations with Loops
      6. Add a Pause or Delay
    5. Chapter 5 Strings and Unstructured Text

      1. Introduction
      2. Create a String
      3. Create a Multiline or Formatted String
      4. Place Special Characters in a String
      5. Insert Dynamic Information in a String
      6. Prevent a String from Including Dynamic Information
      7. Place Formatted Information in a String
      8. Search a String for Text or a Pattern
      9. Replace Text in a String
      10. Split a String on Text or a Pattern
      11. Combine Strings into a Larger String
      12. Convert a String to Upper/Lowercase
      13. Trim a String
      14. Format a Date for Output
      15. Program: Convert Text Streams to Objects
      16. Generate Large Reports and Text Streams
      17. Generate Source Code and Other Repetitive Text
    6. Chapter 6 Calculations and Math

      1. Introduction
      2. Perform Simple Arithmetic
      3. Perform Complex Arithmetic
      4. Measure Statistical Properties of a List
      5. Work with Numbers as Binary
      6. Simplify Math with Administrative Constants
      7. Convert Numbers Between Bases
    7. Chapter 7 Lists, Arrays, and Hashtables

      1. Introduction
      2. Create an Array or List of Items
      3. Create a Jagged or Multidimensional Array
      4. Access Elements of an Array
      5. Visit Each Element of an Array
      6. Sort an Array or List of Items
      7. Determine Whether an Array Contains an Item
      8. Combine Two Arrays
      9. Find Items in an Array That Match a Value
      10. Compare Two Lists
      11. Remove Elements from an Array
      12. Find Items in an Array Greater or Less Than a Value
      13. Use the ArrayList Class for Advanced Array Tasks
      14. Create a Hashtable or Associative Array
      15. Sort a Hashtable by Key or Value
    8. Chapter 8 Utility Tasks

      1. Introduction
      2. Get the System Date and Time
      3. Measure the Duration of a Command
      4. Read and Write from the Windows Clipboard
      5. Generate a Random Number or Object
      6. Program: Search the Windows Start Menu
      7. Program: Show Colorized Script Content
  3. Common Tasks

    1. Chapter 9 Simple Files

      1. Introduction
      2. Get the Content of a File
      3. Search a File for Text or a Pattern
      4. Parse and Manage Text-Based Logfiles
      5. Parse and Manage Binary Files
      6. Create a Temporary File
      7. Search and Replace Text in a File
      8. Program: Get the Encoding of a File
      9. Program: View the Hexadecimal Representation of Content
    2. Chapter 10 Structured Files

      1. Introduction
      2. Access Information in an XML File
      3. Perform an XPath Query Against XML
      4. Convert Objects to XML
      5. Modify Data in an XML File
      6. Easily Import and Export Your Structured Data
      7. Store the Output of a Command in a CSV or Delimited File
      8. Import CSV and Delimited Data from a File
      9. Use Excel to Manage Command Output
      10. Parse and Interpret PowerShell Scripts
    3. Chapter 11 Code Reuse

      1. Introduction
      2. Write a Script
      3. Write a Function
      4. Find a Verb Appropriate for a Command Name
      5. Write a Script Block
      6. Return Data from a Script, Function, or Script Block
      7. Package Common Commands in a Module
      8. Write Commands That Maintain State
      9. Selectively Export Commands from a Module
      10. Diagnose and Interact with Internal Module State
      11. Handle Cleanup Tasks When a Module Is Removed
      12. Access Arguments of a Script, Function, or Script Block
      13. Add Validation to Parameters
      14. Accept Script Block Parameters with Local Variables
      15. Dynamically Compose Command Parameters
      16. Provide -WhatIf, -Confirm, and Other Cmdlet Features
      17. Add Help to Scripts or Functions
      18. Add Custom Tags to a Function or Script Block
      19. Access Pipeline Input
      20. Write Pipeline-Oriented Scripts with Cmdlet Keywords
      21. Write a Pipeline-Oriented Function
      22. Organize Scripts for Improved Readability
      23. Invoke Dynamically Named Commands
      24. Program: Enhance or Extend an Existing Cmdlet
    4. Chapter 12 Internet-Enabled Scripts

      1. Introduction
      2. Download a File from the Internet
      3. Download a Web Page from the Internet
      4. Program: Get-PageUrls
      5. Connect to a Web Service
      6. Program: Connect-WebService
      7. Export Command Output as a Web Page
      8. Send an Email
      9. Program: Send-MailMessage
      10. Program: Interact with Internet Protocols
    5. Chapter 13 User Interaction

      1. Introduction
      2. Read a Line of User Input
      3. Read a Key of User Input
      4. Program: Display a Menu to the User
      5. Display Messages and Output to the User
      6. Provide Progress Updates on Long-Running Tasks
      7. Write Culture-Aware Scripts
      8. Support Other Languages in Script Output
      9. Program: Invoke a Script Block with Alternate Culture Settings
      10. Access Features of the Host’s User Interface
      11. Program: Add a Graphical User Interface to Your Script
      12. Interact with UI Frameworks and STA Objects
    6. Chapter 14 Debugging

      1. Introduction
      2. Prevent Common Scripting Errors
      3. Trace Script Execution
      4. Set a Script Breakpoint
      5. Debug a Script When It Encounters an Error
      6. Create a Conditional Breakpoint
      7. Investigate System State While Debugging
      8. Program: Watch an Expression for Changes
      9. Program: Get Script Code Coverage
    7. Chapter 15 Tracing and Error Management

      1. Introduction
      2. Determine the Status of the Last Command
      3. View the Errors Generated by a Command
      4. Manage the Error Output of Commands
      5. Program: Resolve an Error
      6. Configure Debug, Verbose, and Progress Output
      7. Handle Warnings, Errors, and Terminating Errors
      8. Output Warnings, Errors, and Terminating Errors
      9. Program: Analyze a Script’s Performance Profile
    8. Chapter 16 Environmental Awareness

      1. Introduction
      2. View and Modify Environment Variables
      3. Access Information About Your Command’s Invocation
      4. Program: Investigate the InvocationInfo Variable
      5. Find Your Script’s Name
      6. Find Your Script’s Location
      7. Find the Location of Common System Paths
      8. Get the Current Location
      9. Safely Build File Paths Out of Their Components
      10. Interact with PowerShell’s Global Environment
      11. Determine PowerShell Version Information
    9. Chapter 17 Extend the Reach of Windows PowerShell

      1. Introduction
      2. Automate Programs Using COM Scripting Interfaces
      3. Program: Query a SQL Data Source
      4. Access Windows Performance Counters
      5. Access Windows API Functions
      6. Program: Invoke Simple Windows API Calls
      7. Define or Extend a .NET Class
      8. Add Inline C# to Your PowerShell Script
      9. Access a .NET SDK Library
      10. Create Your Own PowerShell Cmdlet
      11. Add PowerShell Scripting to Your Own Program
    10. Chapter 18 Security and Script Signing

      1. Introduction
      2. Enable Scripting Through an Execution Policy
      3. Disable Warnings for UNC Paths
      4. Sign a PowerShell Script, Module, or Formatting File
      5. Program: Create a Self-Signed Certificate
      6. Manage PowerShell Security in an Enterprise
      7. Block Scripts by Publisher, Path, or Hash
      8. Verify the Digital Signature of a PowerShell Script
      9. Securely Handle Sensitive Information
      10. Securely Request Usernames and Passwords
      11. Program: Start a Process as Another User
      12. Program: Run a Temporarily Elevated Command
      13. Securely Store Credentials on Disk
      14. Access User and Machine Certificates
      15. Program: Search the Certificate Store
      16. Add and Remove Certificates
      17. Manage Security Descriptors in SDDL Form
    11. Chapter 19 Integrated Scripting Environment

      1. Introduction
      2. Debug a Script
      3. Customize Text and User Interface Colors
      4. Connect to a Remote Computer
      5. Extend ISE Functionality Through Its Object Model
      6. Add an Item to the Tools Menu
  4. Administrator Tasks

    1. Chapter 20 Files and Directories

      1. Introduction
      2. Determine the Current Location
      3. Get the Files in a Directory
      4. Find All Files Modified Before a Certain Date
      5. Clear the Content of a File
      6. Manage and Change the Attributes of a File
      7. Find Files That Match a Pattern
      8. Manage Files That Include Special Characters
      9. Program: Get Disk Usage Information
      10. Monitor a File for Changes
      11. Get the Version of a DLL or Executable
      12. Program: Get the MD5 or SHA1 Hash of a File
      13. Create a Directory
      14. Remove a File or Directory
      15. Rename a File or Directory
      16. Move a File or Directory
      17. Program: Move or Remove a Locked File
      18. Get the ACL of a File or Directory
      19. Set the ACL of a File or Directory
      20. Program: Add Extended File Properties to Files
      21. Program: Create a Filesystem Hard Link
      22. Program: Create a ZIP Archive
    2. Chapter 21 The Windows Registry

      1. Introduction
      2. Navigate the Registry
      3. View a Registry Key
      4. Modify or Remove a Registry Key Value
      5. Create a Registry Key Value
      6. Remove a Registry Key
      7. Safely Combine Related Registry Modifications
      8. Add a Site to an Internet Explorer Security Zone
      9. Modify Internet Explorer Settings
      10. Program: Search the Windows Registry
      11. Get the ACL of a Registry Key
      12. Set the ACL of a Registry Key
      13. Work with the Registry of a Remote Computer
      14. Program: Get Registry Items from Remote Machines
      15. Program: Get Properties of Remote Registry Keys
      16. Program: Set Properties of Remote Registry Keys
      17. Discover Registry Settings for Programs
    3. Chapter 22 Comparing Data

      1. Introduction
      2. Compare the Output of Two Commands
      3. Determine the Differences Between Two Files
      4. Verify Integrity of File Sets
    4. Chapter 23 Event Logs

      1. Introduction
      2. List All Event Logs
      3. Get the Newest Entries from an Event Log
      4. Find Event Log Entries with Specific Text
      5. Retrieve and Filter Event Log Entries
      6. Find Event Log Entries by Their Frequency
      7. Back Up an Event Log
      8. Create or Remove an Event Log
      9. Write to an Event Log
      10. Run a PowerShell Script for Windows Event Log Entries
      11. Clear or Maintain an Event Log
      12. Access Event Logs of a Remote Machine
    5. Chapter 24 Processes

      1. Introduction
      2. List Currently Running Processes
      3. Launch the Application Associated with a Document
      4. Launch a Process
      5. Stop a Process
      6. Debug a Process
    6. Chapter 25 System Services

      1. Introduction
      2. List All Running Services
      3. Manage a Running Service
      4. Configure a Service
    7. Chapter 26 Active Directory

      1. Introduction
      2. Test Active Directory Scripts on a Local Installation
      3. Create an Organizational Unit
      4. Get the Properties of an Organizational Unit
      5. Modify Properties of an Organizational Unit
      6. Delete an Organizational Unit
      7. Get the Children of an Active Directory Container
      8. Create a User Account
      9. Program: Import Users in Bulk to Active Directory
      10. Search for a User Account
      11. Get and List the Properties of a User Account
      12. Modify Properties of a User Account
      13. Change a User Password
      14. Create a Security or Distribution Group
      15. Search for a Security or Distribution Group
      16. Get the Properties of a Group
      17. Find the Owner of a Group
      18. Modify Properties of a Security or Distribution Group
      19. Add a User to a Security or Distribution Group
      20. Remove a User from a Security or Distribution Group
      21. List a User’s Group Membership
      22. List the Members of a Group
      23. List the Users in an Organizational Unit
      24. Search for a Computer Account
      25. Get and List the Properties of a Computer Account
    8. Chapter 27 Enterprise Computer Management

      1. Introduction
      2. Join a Computer to a Domain or Workgroup
      3. Remove a Computer from a Domain
      4. Program: List Logon or Logoff Scripts for a User
      5. Program: List Startup or Shutdown Scripts for a Machine
      6. Deploy PowerShell-Based Logon Scripts
      7. Enable or Disable the Windows Firewall
      8. Open or Close Ports in the Windows Firewall
      9. Program: List All Installed Software
      10. Uninstall an Application
      11. Manage Computer Restore Points
      12. Reboot or Shut Down a Computer
      13. Determine Whether a Hotfix Is Installed
      14. Manage Scheduled Tasks on a Computer
      15. Retrieve Printer Information
      16. Retrieve Printer Queue Statistics
      17. Manage Printers and Print Queues
      18. Program: Summarize System Information
      19. Renew a DHCP Lease
      20. Assign a Static IP Address
      21. List All IP Addresses for a Computer
      22. List Network Adapter Properties
    9. Chapter 28 Windows Management Instrumentation

      1. Introduction
      2. Access Windows Management Instrumentation Data
      3. Modify the Properties of a WMI Instance
      4. Invoke a Method on a WMI Class
      5. Program: Determine Properties Available to WMI Filters
      6. Program: Search for WMI Classes
      7. Use .NET to Perform Advanced WMI Tasks
      8. Improve the Performance of Large-Scale WMI Operations
      9. Convert a VBScript WMI Script to PowerShell
    10. Chapter 29 Remoting

      1. Introduction
      2. Find Commands That Support Their Own Remoting
      3. Program: Invoke a PowerShell Expression on a Remote Machine
      4. Test Connectivity Between Two Computers
      5. Limit Networking Scripts to Hosts That Respond
      6. Enable PowerShell Remoting on a Computer
      7. Enable Remote Desktop on a Computer
      8. Program: Remotely Enable PowerShell Remoting
      9. Configure User Permissions for Remoting
      10. Enable Remoting to Workgroup Computers
      11. Interactively Manage a Remote Computer
      12. Invoke a Command on a Remote Computer
      13. Implicitly Invoke Commands from a Remote Computer
      14. Create Sessions with Full Network Access
      15. Pass Variables to Remote Sessions
      16. Configure Advanced Remoting Options
      17. Invoke a Command on Many Computers
      18. Run a Local Script on a Remote Computer
      19. Program: Transfer a File to a Remote Computer
      20. Determine Whether a Script Is Running on a Remote Computer
      21. Program: Create a Task-Specific Remoting Endpoint
    11. Chapter 30 Transactions

      1. Introduction
      2. Safely Experiment with Transactions
      3. Change Error Recovery Behavior in Transactions
    12. Chapter 31 Event Handling

      1. Introduction
      2. Respond to Automatically Generated Events
      3. Create and Respond to Custom Events
      4. Create a Temporary Event Subscription
      5. Forward Events from a Remote Computer
      6. Investigate Internal Event Action State
      7. Use a Script Block as a .NET Delegate or Event Handler
  5. References

    1. Appendix PowerShell Language and Environment

      1. Commands and Expressions
      2. Comments
      3. Variables
      4. Booleans
      5. Strings
      6. Numbers
      7. Arrays and Lists
      8. Hashtables (Associative Arrays)
      9. XML
      10. Simple Operators
      11. Comparison Operators
      12. Conditional Statements
      13. Looping Statements
      14. Working with the .NET Framework
      15. Writing Scripts, Reusing Functionality
      16. Managing Errors
      17. Formatting Output
      18. Capturing Output
      19. Common Customization Points
    2. Appendix Regular Expression Reference

    3. Appendix XPath Quick Reference

    4. Appendix .NET String Formatting

      1. String Formatting Syntax
      2. Standard Numeric Format Strings
      3. Custom Numeric Format Strings
    5. Appendix .NET DateTime Formatting

      1. Custom DateTime Format Strings
    6. Appendix Selected .NET Classes and Their Uses

    7. Appendix WMI Reference

    8. Appendix Selected COM Objects and Their Uses

    9. Appendix Selected Events and Their Uses

    10. Appendix Standard PowerShell Verbs

  1. Colophon