PowerShell Cookbook, 4th Edition

Book description

How do you use PowerShell to navigate the filesystem, manage files and folders, or retrieve a web page? This introduction to the PowerShell language and scripting environment provides more than 400 task-oriented recipes to help you solve all kinds of problems. Intermediate to advanced system administrators will find more than 100 tried-and-tested scripts they can copy and use immediately.

Updated for PowerShell 5, Open Source PowerShell up to 7 and beyond, this comprehensive cookbook includes hands-on recipes for common tasks and administrative jobs that you can apply whether you're on the client or server version of Windows. You also get quick references to technologies used in conjunction with PowerShell, including format specifiers and frequently referenced registry keys to selected .NET, COM, and WMI classes.

  • Learn how to use PowerShell on Windows 10 and Windows Server 2019
  • Tour PowerShell's core features, including the command model, object-based pipeline, and ubiquitous scripting
  • Master fundamentals such as the interactive shell, pipeline, and object concepts
  • Perform common tasks that involve working with files, Internet-connected scripts, user interaction, and more
  • Solve tasks in systems and enterprise management, such as working with Active Directory and the filesystem

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Who This Book Is For
    2. How This Book Is Organized
    3. What You Need to Use This Book
    4. Conventions Used in This Book
    5. Access this Book in Digital Format
    6. Code Examples
    7. O’Reilly Online Learning
    8. How to Contact Us
    9. Acknowledgments
  3. Tour
  4. A Guided Tour of 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
  5. Fundamentals
  6. 1. The PowerShell Interactive Shell
    1. 1.0. Introduction
    2. 1.1. Install PowerShell Core
    3. 1.2. Run Programs, Scripts, and Existing Tools
    4. 1.3. Run a PowerShell Command
    5. 1.4. Resolve Errors Calling Native Executables
    6. 1.5. Supply Default Values for Parameters
    7. 1.6. Invoke a Long-Running or Background Command
    8. 1.7. Program: Monitor a Command for Changes
    9. 1.8. Notify Yourself of Job Completion
    10. 1.9. Customize Your Shell, Profile, and Prompt
    11. 1.10. Customize PowerShell’s User Input Behavior
    12. 1.11. Customize PowerShell’s Command Resolution Behavior
    13. 1.12. Find a Command to Accomplish a Task
    14. 1.13. Get Help on a Command
    15. 1.14. Update System Help Content
    16. 1.15. Program: Search Help for Text
    17. 1.16. Launch PowerShell at a Specific Location
    18. 1.17. Invoke a PowerShell Command or Script from Outside PowerShell
    19. 1.18. Understand and Customize PowerShell’s Tab Completion
    20. 1.19. Program: Learn Aliases for Common Commands
    21. 1.20. Program: Learn Aliases for Common Parameters
    22. 1.21. Access and Manage Your Console History
    23. 1.22. Program: Create Scripts from Your Session History
    24. 1.23. Invoke a Command from Your Session History
    25. 1.24. Program: Search Formatted Output for a Pattern
    26. 1.25. Interactively View and Process Command Output
    27. 1.26. Program: Interactively View and Explore Objects
    28. 1.27. Record a Transcript of Your Shell Session
    29. 1.28. Extend Your Shell with Additional Commands
    30. 1.29. Find and Install Additional PowerShell Scripts and Modules
    31. 1.30. Use Commands from Customized Shells
    32. 1.31. Save State Between Sessions
  7. 2. Pipelines
    1. 2.0. Introduction
    2. 2.1. Chain Commands Based on their Success or Error
    3. 2.2. Filter Items in a List or Command Output
    4. 2.3. Group and Pivot Data by Name
    5. 2.4. Interactively Filter Lists of Objects
    6. 2.5. Work with Each Item in a List or Command Output
    7. 2.6. Automate Data-Intensive Tasks
    8. 2.7. Intercept Stages of the Pipeline
    9. 2.8. Automatically Capture Pipeline Output
    10. 2.9. Capture and Redirect Binary Process Output
  8. 3. Variables and Objects
    1. 3.0. Introduction
    2. 3.1. Display the Properties of an Item as a List
    3. 3.2. Display the Properties of an Item as a Table
    4. 3.3. Store Information in Variables
    5. 3.4. Access Environment Variables
    6. 3.5. Program: Retain Changes to Environment Variables Set by a Batch File
    7. 3.6. Control Access and Scope of Variables and Other Items
    8. 3.7. Program: Create a Dynamic Variable
    9. 3.8. Work with .NET Objects
    10. 3.9. Create an Instance of a .NET Object
    11. 3.10. Create Instances of Generic Objects
    12. 3.11. Use a COM Object
    13. 3.12. Learn About Types and Objects
    14. 3.13. Get Detailed Documentation About Types and Objects
    15. 3.14. Add Custom Methods and Properties to Objects
    16. 3.15. Create and Initialize Custom Objects
    17. 3.16. Add Custom Methods and Properties to Types
    18. 3.17. Define Custom Formatting for a Type
  9. 4. Looping and Flow Control
    1. 4.0. Introduction
    2. 4.1. Make Decisions with Comparison and Logical Operators
    3. 4.2. Adjust Script Flow Using Conditional Statements
    4. 4.3. Manage Large Conditional Statements with Switches
    5. 4.4. Repeat Operations with Loops
    6. 4.5. Process Time-Consuming Action in Parallel
    7. 4.6. Add a Pause or Delay
  10. 5. Strings and Unstructured Text
    1. 5.0. Introduction
    2. 5.1. Create a String
    3. 5.2. Create a Multiline or Formatted String
    4. 5.3. Place Special Characters in a String
    5. 5.4. Insert Dynamic Information in a String
    6. 5.5. Prevent a String from Including Dynamic Information
    7. 5.6. Place Formatted Information in a String
    8. 5.7. Search a String for Text or a Pattern
    9. 5.8. Replace Text in a String
    10. 5.9. Split a String on Text or a Pattern
    11. 5.10. Combine Strings into a Larger String
    12. 5.11. Convert a String to Uppercase or Lowercase
    13. 5.12. Trim a String
    14. 5.13. Format a Date for Output
    15. 5.14. Convert a String Between One Format and Another
    16. 5.15. Convert Text Streams to Objects
    17. 5.16. Generate Large Reports and Text Streams
    18. 5.17. Generate Source Code and Other Repetitive Text
  11. 6. Calculations and Math
    1. 6.0. Introduction
    2. 6.1. Perform Simple Arithmetic
    3. 6.2. Perform Complex Arithmetic
    4. 6.3. Measure Statistical Properties of a List
    5. 6.4. Work with Numbers as Binary
    6. 6.5. Simplify Math with Administrative Constants
    7. 6.6. Convert Numbers Between Bases
  12. 7. Lists, Arrays, and Hashtables
    1. 7.0. Introduction
    2. 7.1. Create an Array or List of Items
    3. 7.2. Create a Jagged or Multidimensional Array
    4. 7.3. Access Elements of an Array
    5. 7.4. Visit Each Element of an Array
    6. 7.5. Sort an Array or List of Items
    7. 7.6. Determine Whether an Array Contains an Item
    8. 7.7. Combine Two Arrays
    9. 7.8. Find Items in an Array That Match a Value
    10. 7.9. Compare Two Lists
    11. 7.10. Remove Elements from an Array
    12. 7.11. Find Items in an Array Greater or Less Than a Value
    13. 7.12. Use the ArrayList Class for Advanced Array Tasks
    14. 7.13. Create a Hashtable or Associative Array
    15. 7.14. Sort a Hashtable by Key or Value
  13. 8. Utility Tasks
    1. 8.0. Introduction
    2. 8.1. Get the System Date and Time
    3. 8.2. Measure the Duration of a Command
    4. 8.3. Read and Write from the Clipboard
    5. 8.4. Generate a Random Number or Object
    6. 8.5. Convert Time Between Time Zones
    7. 8.6. Program: Search the Windows Start Menu
    8. 8.7. Program: Show Colorized Script Content
  14. Common Tasks
  15. 9. Simple Files
    1. 9.0. Introduction
    2. 9.1. Get the Content of a File
    3. 9.2. Store the Output of a Command into a File
    4. 9.3. Add Information to the End of a File
    5. 9.4. Search a File for Text or a Pattern
    6. 9.5. Parse and Manage Text-Based Logfiles
    7. 9.6. Parse and Manage Binary Files
    8. 9.7. Create and Manage Temporary Files
    9. 9.8. Search and Replace Text in a File
    10. 9.9. Program: Get the Encoding of a File
    11. 9.10. View the Hexadecimal Representation of Content
  16. 10. Structured Files
    1. 10.0. Introduction
    2. 10.1. Access Information in an XML File
    3. 10.2. Perform an XPath Query Against XML
    4. 10.3. Convert Objects to XML
    5. 10.4. Modify Data in an XML File
    6. 10.5. Easily Import and Export Your Structured Data
    7. 10.6. Store the Output of a Command in a CSV or Delimited File
    8. 10.7. Import CSV and Delimited Data from a File
    9. 10.8. Manage JSON Data Streams
    10. 10.9. Use Excel to Manage Command Output
    11. 10.10. Parse and Interpret PowerShell Scripts
  17. 11. Code Reuse
    1. 11.0. Introduction
    2. 11.1. Write a Script
    3. 11.2. Write a Function
    4. 11.3. Find a Verb Appropriate for a Command Name
    5. 11.4. Write a Script Block
    6. 11.5. Return Data from a Script, Function, or Script Block
    7. 11.6. Package Common Commands in a Module
    8. 11.7. Write Commands That Maintain State
    9. 11.8. Selectively Export Commands from a Module
    10. 11.9. Diagnose and Interact with Internal Module State
    11. 11.10. Handle Cleanup Tasks When a Module Is Removed
    12. 11.11. Access Arguments of a Script, Function, or Script Block
    13. 11.12. Add Validation to Parameters
    14. 11.13. Accept Script Block Parameters with Local Variables
    15. 11.14. Dynamically Compose Command Parameters
    16. 11.15. Provide -WhatIf, -Confirm, and Other Cmdlet Features
    17. 11.16. Add Help to Scripts or Functions
    18. 11.17. Add Custom Tags to a Function or Script Block
    19. 11.18. Access Pipeline Input
    20. 11.19. Write Pipeline-Oriented Scripts with Cmdlet Keywords
    21. 11.20. Write a Pipeline-Oriented Function
    22. 11.21. Organize Scripts for Improved Readability
    23. 11.22. Invoke Dynamically Named Commands
    24. 11.23. Program: Enhance or Extend an Existing Cmdlet
  18. 12. Internet-Enabled Scripts
    1. 12.0. Introduction
    2. 12.1. Download a File from an FTP or Internet Site
    3. 12.2. Upload a File to an FTP Site
    4. 12.3. Program: Resolve the Destination of an Internet Redirect
    5. 12.4. Download a Web Page from the Internet
    6. 12.5. Parse and Analyze a Web Page from the Internet
    7. 12.6. Script a Web Application Session
    8. 12.7. Interact with REST-Based Web APIs
    9. 12.8. Connect to a Web Service
    10. 12.9. Interact with and Manage Remote SSL Certificates
    11. 12.10. Export Command Output as a Web Page
    12. 12.11. Send an Email
    13. 12.12. Program: Monitor Website Uptimes
    14. 12.13. Program: Interact with Internet Protocols
  19. 13. User Interaction
    1. 13.0. Introduction
    2. 13.1. Read a Line of User Input
    3. 13.2. Read a Key of User Input
    4. 13.3. Program: Display a Menu to the User
    5. 13.4. Display Messages and Output to the User
    6. 13.5. Provide Progress Updates on Long-Running Tasks
    7. 13.6. Write Culture-Aware Scripts
    8. 13.7. Support Other Languages in Script Output
    9. 13.8. Program: Invoke a Script Block with Alternate Culture Settings
    10. 13.9. Access Features of the Host’s User Interface
    11. 13.10. Add a Graphical User Interface to Your Script
    12. 13.11. Program: Add a Console User Interface to Your Script
    13. 13.12. Interact with MTA Objects
  20. 14. Debugging
    1. 14.0. Introduction
    2. 14.1. Prevent Common Scripting Errors
    3. 14.2. Write Unit Tests for your Scripts
    4. 14.3. Trace Script Execution
    5. 14.4. Set a Script Breakpoint
    6. 14.5. Debug a Script When It Encounters an Error
    7. 14.6. Create a Conditional Breakpoint
    8. 14.7. Investigate System State While Debugging
    9. 14.8. Debug a Script on a Remote Machine
    10. 14.9. Program: Watch an Expression for Changes
    11. 14.10. Debug a Script in Another Process
    12. 14.11. Program: Get Script Code Coverage
  21. 15. Tracing and Error Management
    1. 15.0. Introduction
    2. 15.1. Determine the Status of the Last Command
    3. 15.2. View the Errors Generated by a Command
    4. 15.3. Manage the Error Output of Commands
    5. 15.4. Program: Resolve an Error
    6. 15.5. Configure Debug, Verbose, and Progress Output
    7. 15.6. Handle Warnings, Errors, and Terminating Errors
    8. 15.7. Output Warnings, Errors, and Terminating Errors
    9. 15.8. Analyze a Script’s Performance Profile
  22. 16. Environmental Awareness
    1. 16.0. Introduction
    2. 16.1. View and Modify Environment Variables
    3. 16.2. Modify the User or System Path
    4. 16.3. Access Information About Your Command’s Invocation
    5. 16.4. Program: Investigate the InvocationInfo Variable
    6. 16.5. Find Your Script’s Name
    7. 16.6. Find Your Script’s Location
    8. 16.7. Find the Location of Common System Paths
    9. 16.8. Get the Current Location
    10. 16.9. Safely Build File Paths Out of Their Components
    11. 16.10. Interact with PowerShell’s Global Environment
    12. 16.11. Determine PowerShell Version Information
    13. 16.12. Test for Administrative Privileges
  23. 17. Extend the Reach of PowerShell
    1. 17.0. Introduction
    2. 17.1. Automate Programs Using COM Scripting Interfaces
    3. 17.2. Program: Query a SQL Data Source
    4. 17.3. Access Windows Performance Counters
    5. 17.4. Access Windows API Functions
    6. 17.5. Program: Invoke Simple Windows API Calls
    7. 17.6. Define or Extend a .NET Class
    8. 17.7. Add Inline C# to Your PowerShell Script
    9. 17.8. Access a .NET SDK Library
    10. 17.9. Create Your Own PowerShell Cmdlet
    11. 17.10. Add PowerShell Scripting to Your Own Program
  24. 18. Security and Script Signing
    1. 18.0. Introduction
    2. 18.1. Enable Scripting Through an Execution Policy
    3. 18.2. Enable PowerShell Security Logging
    4. 18.3. Disable Warnings for UNC Paths
    5. 18.4. Sign a PowerShell Script, Module, or Formatting File
    6. 18.5. Create a Self-Signed Certificate
    7. 18.6. Manage PowerShell Security in an Enterprise
    8. 18.7. Block Scripts by Publisher, Path, or Hash
    9. 18.8. Verify the Digital Signature of a PowerShell Script
    10. 18.9. Securely Handle Sensitive Information
    11. 18.10. Securely Request Usernames and Passwords
    12. 18.11. Start a Process as Another User
    13. 18.12. Program: Run a Temporarily Elevated Command
    14. 18.13. Securely Store Credentials on Disk
    15. 18.14. Access User and Machine Certificates
    16. 18.15. Program: Search the Certificate Store
    17. 18.16. Add and Remove Certificates
    18. 18.17. Manage Security Descriptors in SDDL Form
    19. 18.18. Create a Task-Specific Remoting Endpoint
    20. 18.19. Limit Interactive Use of PowerShell
    21. 18.20. Detect and Prevent Code Injection Vulnerabilities
    22. 18.21. Get the Cryptographic Hash of a File
    23. 18.22. Capture and Validate Integrity of File Sets
  25. 19. Visual Studio Code
    1. 19.0. Introduction
    2. 19.1. Debug a Script
    3. 19.2. Connect to a Remote Computer
    4. 19.3. Interact with Visual Studio Code through its Object Model
    5. 19.4. Quickly Insert Script Snippets
  26. Administrator Tasks
  27. 20. Files and Directories
    1. 20.0. Introduction
    2. 20.1. Determine and Change the Current Location
    3. 20.2. Get the Files in a Directory
    4. 20.3. Find All Files Modified Before a Certain Date
    5. 20.4. Clear the Content of a File
    6. 20.5. Manage and Change the Attributes of a File
    7. 20.6. Find Files That Match a Pattern
    8. 20.7. Manage Files That Include Special Characters
    9. 20.8. Program: Get Disk Usage Information
    10. 20.9. Monitor a File for Changes
    11. 20.10. Get the Version of a DLL or Executable
    12. 20.11. Create a Directory
    13. 20.12. Remove a File or Directory
    14. 20.13. Rename a File or Directory
    15. 20.14. Move a File or Directory
    16. 20.15. Create and Map PowerShell Drives
    17. 20.16. Access Long File and Directory Names
    18. 20.17. Unblock a File
    19. 20.18. Interact with Alternate Data Streams
    20. 20.19. Program: Move or Remove a Locked File
    21. 20.20. Get the ACL of a File or Directory
    22. 20.21. Set the ACL of a File or Directory
    23. 20.22. Program: Add Extended File Properties to Files
    24. 20.23. Manage ZIP Archives
  28. 21. The Windows Registry
    1. 21.0. Introduction
    2. 21.1. Navigate the Registry
    3. 21.2. View a Registry Key
    4. 21.3. Modify or Remove a Registry Key Value
    5. 21.4. Create a Registry Key Value
    6. 21.5. Remove a Registry Key
    7. 21.6. Safely Combine Related Registry Modifications
    8. 21.7. Add a Site to an Internet Explorer Security Zone
    9. 21.8. Modify Internet Explorer Settings
    10. 21.9. Program: Search the Windows Registry
    11. 21.10. Get the ACL of a Registry Key
    12. 21.11. Set the ACL of a Registry Key
    13. 21.12. Work with the Registry of a Remote Computer
    14. 21.13. Program: Get Registry Items from Remote Machines
    15. 21.14. Program: Get Properties of Remote Registry Keys
    16. 21.15. Program: Set Properties of Remote Registry Keys
    17. 21.16. Discover Registry Settings for Programs
  29. 22. Comparing Data
    1. 22.0. Introduction
    2. 22.1. Compare the Output of Two Commands
    3. 22.2. Determine the Differences Between Two Files
  30. 23. Event Logs
    1. 23.0. Introduction
    2. 23.1. List All Event Logs
    3. 23.2. Get the Oldest Entries from an Event Log
    4. 23.3. Find Event Log Entries with Specific Text
    5. 23.4. Retrieve and Filter Event Log Entries
    6. 23.5. Find Event Log Entries by Their Frequency
    7. 23.6. Back Up an Event Log
    8. 23.7. Create or Remove an Event Log
    9. 23.8. Write to an Event Log
    10. 23.9. Run a PowerShell Script for Windows Event Log Entries
    11. 23.10. Clear or Maintain an Event Log
    12. 23.11. Access Event Logs of a Remote Machine
  31. 24. Processes
    1. 24.0. Introduction
    2. 24.1. List Currently Running Processes
    3. 24.2. Launch the Application Associated with a Document
    4. 24.3. Launch a Process
    5. 24.4. Stop a Process
    6. 24.5. Get the Owner of a Process
    7. 24.6. Get the Parent Process of a Process
    8. 24.7. Debug a Process
  32. 25. System Services
    1. 25.0. Introduction
    2. 25.1. List All Running Services
    3. 25.2. Manage a Running Service
    4. 25.3. Configure a Service
  33. 26. Active Directory
    1. 26.0. Introduction
    2. 26.1. Test Active Directory Scripts on a Local Installation
    3. 26.2. Create an Organizational Unit
    4. 26.3. Get the Properties of an Organizational Unit
    5. 26.4. Modify Properties of an Organizational Unit
    6. 26.5. Delete an Organizational Unit
    7. 26.6. Get the Children of an Active Directory Container
    8. 26.7. Create a User Account
    9. 26.8. Program: Import Users in Bulk to Active Directory
    10. 26.9. Search for a User Account
    11. 26.10. Get and List the Properties of a User Account
    12. 26.11. Modify Properties of a User Account
    13. 26.12. Change a User Password
    14. 26.13. Create a Security or Distribution Group
    15. 26.14. Search for a Security or Distribution Group
    16. 26.15. Get the Properties of a Group
    17. 26.16. Find the Owner of a Group
    18. 26.17. Modify Properties of a Security or Distribution Group
    19. 26.18. Add a User to a Security or Distribution Group
    20. 26.19. Remove a User from a Security or Distribution Group
    21. 26.20. List a User’s Group Membership
    22. 26.21. List the Members of a Group
    23. 26.22. List the Users in an Organizational Unit
    24. 26.23. Search for a Computer Account
    25. 26.24. Get and List the Properties of a Computer Account
  34. 27. Enterprise Computer Management
    1. 27.0. Introduction
    2. 27.1. Join a Computer to a Domain or Workgroup
    3. 27.2. Remove a Computer from a Domain
    4. 27.3. Rename a Computer
    5. 27.4. Program: List Logon or Logoff Scripts for a User
    6. 27.5. Program: List Startup or Shutdown Scripts for a Machine
    7. 27.6. Deploy PowerShell-Based Logon Scripts
    8. 27.7. Enable or Disable the Windows Firewall
    9. 27.8. Open or Close Ports in the Windows Firewall
    10. 27.9. Program: List All Installed Software
    11. 27.10. Uninstall an Application
    12. 27.11. Manage Computer Restore Points
    13. 27.12. Reboot or Shut Down a Computer
    14. 27.13. Determine Whether a Hotfix Is Installed
    15. 27.14. Manage Scheduled Tasks on a Computer
    16. 27.15. Retrieve Printer Information
    17. 27.16. Retrieve Printer Queue Statistics
    18. 27.17. Manage Printers and Print Queues
    19. 27.18. Program: Summarize System Information
    20. 27.19. Renew a DHCP Lease
    21. 27.20. Assign a Static IP Address
    22. 27.21. List All IP Addresses for a Computer
    23. 27.22. List Network Adapter Properties
  35. 28. Windows Management Instrumentation
    1. 28.0. Introduction
    2. 28.1. Access Windows Management Instrumentation and CIM Data
    3. 28.2. Modify the Properties of a WMI or CIM Instance
    4. 28.3. Invoke a Method on a WMI Instance or Class
    5. 28.4. Program: Determine Properties Available to WMI and CIM Filters
    6. 28.5. Search for the WMI or CIM Class to Accomplish a Task
    7. 28.6. Use .NET to Perform Advanced WMI Tasks
    8. 28.7. Convert a VBScript WMI Script to PowerShell
  36. 29. Remoting
    1. 29.0. Introduction
    2. 29.1. Find Commands That Support Their Own Remoting
    3. 29.2. Enable PowerShell Remoting on a Computer
    4. 29.3. Enable SSH as a PowerShell Remoting Transport
    5. 29.4. Interactively Manage a Remote Computer
    6. 29.5. Invoke a Command on a Remote Computer
    7. 29.6. Disconnect and Reconnect PowerShell Sessions
    8. 29.7. Program: Remotely Enable PowerShell Remoting
    9. 29.8. Program: Invoke a PowerShell Expression on a Remote Machine
    10. 29.9. Test Connectivity Between Two Computers
    11. 29.10. Limit Networking Scripts to Hosts That Respond
    12. 29.11. Enable Remote Desktop on a Computer
    13. 29.12. Configure User Permissions for Remoting
    14. 29.13. Enable Remoting to Workgroup Computers
    15. 29.14. Implicitly Invoke Commands from a Remote Computer
    16. 29.15. Create Sessions with Full Network Access
    17. 29.16. Pass Variables to Remote Sessions
    18. 29.17. Manage and Edit Files on Remote Machines
    19. 29.18. Configure Advanced Remoting Quotas and Options
    20. 29.19. Invoke a Command on Many Computers
    21. 29.20. Run a Local Script on a Remote Computer
    22. 29.21. Determine Whether a Script Is Running on a Remote Computer
  37. 30. Transactions
    1. 30.0. Introduction
    2. 30.1. Safely Experiment with Transactions
    3. 30.2. Change Error Recovery Behavior in Transactions
  38. 31. Event Handling
    1. 31.0. Introduction
    2. 31.1. Respond to Automatically Generated Events
    3. 31.2. Create and Respond to Custom Events
    4. 31.3. Create a Temporary Event Subscription
    5. 31.4. Forward Events from a Remote Computer
    6. 31.5. Investigate Internal Event Action State
    7. 31.6. Use a Script Block as a .NET Delegate or Event Handler
  39. References
  40. PowerShell Language and Environment
    1. Commands and Expressions
    2. Comments
    3. Help Comments
    4. Variables
    5. Booleans
    6. Strings
    7. Numbers
    8. Arrays and Lists
    9. Hashtables (Associative Arrays)
    10. XML
    11. Simple Operators
    12. Comparison Operators
    13. Conditional Statements
    14. Looping Statements
    15. Working with the .NET Framework
    16. Writing Scripts, Reusing Functionality
    17. Managing Errors
    18. Formatting Output
    19. Capturing Output
    20. Common Customization Points
  41. Regular Expression Reference
  42. XPath Quick Reference
  43. .NET String Formatting
    1. String Formatting Syntax
    2. Standard Numeric Format Strings
    3. Custom Numeric Format Strings
  44. .NET DateTime Formatting
    1. Custom DateTime Format Strings
  45. Selected .NET Classes and Their Uses
  46. WMI Reference
  47. Selected COM Objects and Their Uses
  48. Selected Events and Their Uses
  49. Standard PowerShell Verbs

Product information

  • Title: PowerShell Cookbook, 4th Edition
  • Author(s): Lee Holmes
  • Release date: July 2021
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098101602