Windows PowerShell 3.0 First Steps

Book description

Get started with this powerful Windows administration tool

Automate Windows administration tasks with ease by learning the fundamentals of Windows PowerShell 3.0. Led by a Windows PowerShell expert, you’ll learn must-know concepts and techniques through easy-to-follow explanations, examples, and exercises. Once you complete this practical introduction, you can go deeper into the Windows PowerShell command line interface and scripting language with Windows PowerShell 3.0 Step by Step.

Discover how to:

  • Create effective Windows PowerShell commands with one line of code

  • Apply Windows PowerShell commands across several Windows platforms

  • Identify missing hotfixes and service packs with a single command

  • Sort, group, and filter data using the Windows PowerShell pipeline

  • Create users, groups, and organizational units in Active Directory

  • Add computers to a domain or workgroup with a single line of code

  • Run Windows PowerShell commands on multiple remote computers

  • Unleash the power of scripting with Windows Management Instrumentation (WMI)

  • Table of contents

    1. Dedication
    2. Foreword
    3. Introduction
      1. System Requirements
        1. Hardware Requirements
        2. Software Requirements
      2. Acknowledgments
      3. Support & Feedback
          1. Errata
          2. We Want to Hear from You
          3. Stay in Touch
    4. 1. Overview of Windows PowerShell 3.0
      1. Understanding Windows PowerShell
      2. Working with Windows PowerShell
        1. Security issues with Windows PowerShell
          1. Running as a non-elevated user
          2. Launching Windows PowerShell with administrator rights
      3. Using Windows PowerShell cmdlets
        1. The most common verb: Get
          1. Finding process information
          2. Identifying installed Windows hotfixes
          3. Getting detailed service information
          4. Identifying installed network adapters
          5. Retrieving detected network connection profiles
          6. Getting the current culture settings
          7. Finding the current date and time
          8. Generating a random number
      4. Supplying options for cmdlets
        1. Using single parameters
          1. Finding specific types of hotfixes
          2. Finding specific processes
          3. Generating random numbers in a range
        2. Introduction to parameter sets
          1. Generating a certain number of random numbers
        3. Using command-line utilities
      5. Working with Help options
      6. Summary
    5. 2. Using Windows PowerShell cmdlets
      1. Understanding the basics of cmdlets
        1. Common Windows PowerShell parameters
          1. Using the Verbose parameter to provide additional information
          2. Using the ErrorAction parameter to hide errors
        2. Starting the Windows PowerShell transcript
        3. Stopping and reviewing the Windows PowerShell transcript
      2. Searching the Help topics
        1. Using the Get-Help cmdlet
          1. Paging the Help output
          2. Using the Get-Help cmdlet to search for Windows PowerShell cmdlets
        2. Using the About conceptual Help topics
      3. Using the Get-Command to find cmdlets
      4. Using the Get-Member cmdlet
        1. Exploring property members
      5. Using the Show-Command cmdlet
      6. Setting the Script Execution Policy
      7. Creating a basic Windows PowerShell profile
        1. Determining if a Windows PowerShell profile exists
        2. Creating a new Windows PowerShell profile
      8. Summary
    6. 3. Filtering, grouping, and sorting
      1. Introduction to the pipeline
      2. Sorting output from a cmdlet
      3. Grouping output after sorting
        1. Grouping information without element data
      4. Filtering output from one cmdlet
        1. Filtering by date
        2. Filtering to the left
      5. Filtering output from one cmdlet before sorting
      6. Summary
    7. 4. Formatting output
      1. Creating a table
        1. Choosing specific properties in a specific order
        2. Controlling the way the table displays
      2. Creating a list
        1. Choosing properties by name
        2. Choosing properties by wildcard
      3. Creating a wide display
        1. Using the -AutoSize parameter to configure the output
        2. Customizing the Format-Wide output
      4. Creating an output grid
        1. Sorting output by using the column buttons
        2. Filtering output by using the filter box
      5. Summary
    8. 5. Storing output
      1. Storing data in text files
        1. Redirect and append
        2. Redirect and overwrite
        3. Controlling the text file
      2. Storing data in .csv files
        1. No type information
        2. Using type information
      3. Storing data in XML
        1. The problem with complex objects
        2. Using XML to store complex objects
      4. Summary
    9. 6. Leveraging Windows PowerShell providers
      1. Understanding Windows PowerShell providers
        1. Understanding the Alias provider
        2. Understanding the Certificate provider
          1. Searching for specific certificates
          2. Finding expiring certificates
        3. Understanding the Environment provider
        4. Understanding the File System provider
        5. Understanding the Function provider
        6. Understanding the Registry provider
          1. The two registry drives
          2. Retrieving registry values
          3. Creating new registry keys
          4. The short way to create a new registry key
          5. Setting the default value for the key
          6. Using New-Item to create and assign a value
          7. Modifying the value of a registry property value
          8. Dealing with a missing registry property value
        7. Understanding the Variable provider
      2. Summary
    10. 7. Using Windows PowerShell remoting
      1. Using Windows PowerShell remoting
        1. Classic remoting
      2. Configuring Windows PowerShell remoting
        1. Running commands
          1. Running a single Windows PowerShell command
          2. Running a single command against multiple computers
        2. Creating a persisted connection
      3. Troubleshooting Windows PowerShell remoting
      4. Summary
    11. 8. Using WMI
      1. Understanding the WMI Model
        1. Working with objects and namespaces
        2. Listing WMI providers
        3. Working with WMI classes
      2. Querying WMI: The basics
        1. Tell me everything about everything
        2. Tell me selected things about everything
        3. Tell me everything about some things
        4. Tell me selected things about some things
      3. Summary
    12. 9. Using CIM
      1. Using CIM cmdlets to explore WMI classes
        1. Using the classname parameter
        2. Finding WMI class methods
        3. Filtering classes by qualifier
      2. Retrieving WMI instances
        1. Reducing returned properties and instances
        2. Cleaning up output from the command
      3. Working with associations
      4. Summary
    13. 10. Using the Windows PowerShell ISE
      1. Running the Windows PowerShell ISE
        1. Navigating the Windows PowerShell ISE
        2. Working with the Script pane
        3. Tab expansion and Intellisense
      2. Working with Windows PowerShell ISE snippets
        1. Using Windows PowerShell ISE snippets to create code
        2. Creating new Windows PowerShell ISE snippets
        3. Removing user-defined Windows PowerShell ISE snippets
      3. Summary
    14. 11. Using Windows PowerShell scripts
      1. Why write Windows PowerShell scripts?
      2. Scripting fundamentals
        1. Running Windows PowerShell scripts
        2. Enabling Windows PowerShell scripting support
        3. Transitioning from command line to script
        4. Running Windows PowerShell scripts
        5. Understanding variables and constants
          1. Using variables
      3. Using the While statement
        1. Constructing the While statement
          1. Understanding expanding strings
          2. Understanding literal strings
        2. A practical example of using the While statement
        3. Using special features of Windows PowerShell
      4. Using the Do…While statement
        1. Using the range operator
        2. Operating over an array
        3. Casting to ASCII values
      5. Using the Do…Until statement
        1. Using the Windows PowerShell Do…Loop statement
          1. The Do…While and Do…Until statements always run once
          2. The While statement is used to prevent unwanted execution
      6. Using the For statement
        1. Creating a For…Loop
        2. Using the ForEach statement
          1. Using the ForEach statement from the Windows PowerShell console
        3. Exiting the ForEach statement early
          1. Using the Break statement
          2. Using the Exit statement
      7. Using the If statement
        1. Using assignment and comparison operators
        2. Evaluating multiple conditions
      8. Using the Switch statement
        1. Using the basic Switch statement
          1. Defining the Default condition
          2. Understanding matching
          3. Evaluating an array
        2. Controlling matching behavior
      9. Summary
    15. 12. Working with functions
      1. Understanding functions
        1. Using a type constraint
      2. Using multiple input parameters
      3. Using functions to encapsulate business logic
      4. Using functions to provide ease of modification
      5. Summary
    16. 13. Debugging scripts
      1. Understanding debugging in Windows PowerShell
      2. Debugging the script
        1. Setting breakpoints
        2. Setting a breakpoint on a line number
        3. Setting a breakpoint on a variable
        4. Setting a breakpoint on a command
        5. Responding to breakpoints
        6. Listing breakpoints
        7. Enabling and disabling breakpoints
        8. Deleting breakpoints
      3. Summary
    17. 14. Handling errors
      1. Handling missing parameters
        1. Creating a default value for the parameter
          1. Detecting the missing value and assigning it in the script
          2. Assigning the value in the Param statement
        2. Making the parameter mandatory
      2. Limiting choices
        1. Using PromptForChoice to limit selections
        2. Using Test-Connection to identify accessible computers
        3. Using the contains operator to examine contents of an array
      3. Handling missing rights
        1. Attempting and failing
        2. Checking for rights and exiting gracefully
      4. Using Try/Catch/Finally
      5. Summary
    18. A. Windows PowerShell FAQ
    19. B. Windows PowerShell 3.0 coding conventions
      1. General script construction
        1. Include functions in the script that uses the functions
        2. Use full cmdlet names and full parameter names
          1. Understanding the use of aliases
          2. If you must use an alias, use only canonical aliases in a script
          3. Always use the Description property when creating an alias
        3. Use Get-Item to convert path strings to rich types
      2. General script readability
      3. Formatting your code
        1. Working with functions
        2. Creating template files
        3. Writing your own functions
        4. Variables, constants, and naming
    20. Index
    21. About the Author
    22. Copyright

    Product information

    • Title: Windows PowerShell 3.0 First Steps
    • Author(s): Ed Wilson
    • Release date: July 2013
    • Publisher(s): Microsoft Press
    • ISBN: 9780735680999