| |
| |
Foreword | |
| |
| |
Introduction | |
| |
| |
| |
Overview of Windows PowerShell 3.0 | |
| |
| |
Understanding Windows PowerShell | |
| |
| |
Working with Windows PowerShell | |
| |
| |
Security issues with Windows PowerShell | |
| |
| |
Using Windows PowerShell cmdlets | |
| |
| |
The most common verb: Get | |
| |
| |
Supplying options for cmdlets | |
| |
| |
Using single parameters | |
| |
| |
Introduction to parameter sets | |
| |
| |
Using command-line utilities | |
| |
| |
Working with Help options | |
| |
| |
Summary | |
| |
| |
| |
Using Windows PowerShell cmdlets | |
| |
| |
Understanding the basics of cmdlets | |
| |
| |
Common Windows PowerShell parameters | |
| |
| |
Starting the Windows PowerShell transcript | |
| |
| |
Stopping and reviewing the Windows PowerShell transcript | |
| |
| |
Searching the Help topics | |
| |
| |
Using the Get-Help cmdlet | |
| |
| |
Using the About conceptual Help topics | |
| |
| |
Using the Get-Command to find cmdlets | |
| |
| |
Using the Get-Member cmdlet | |
| |
| |
Exploring property members | |
| |
| |
Using the Show-Command cmdlet | |
| |
| |
Setting the Script Execution Policy | |
| |
| |
Creating a basic Windows PowerShell profile | |
| |
| |
Determining if a Windows PowerShell profile exists | |
| |
| |
Creating a new Windows PowerShell profile | |
| |
| |
Summary | |
| |
| |
| |
Filtering, grouping, and sorting | |
| |
| |
Introduction to the pipeline | |
| |
| |
Sorting output from a cmdlet | |
| |
| |
Grouping output after sorting | |
| |
| |
Grouping information without element data | |
| |
| |
Filtering output from one cmdlet | |
| |
| |
Filtering by date | |
| |
| |
Filtering to the left | |
| |
| |
Filtering output from one cmdlet before sorting | |
| |
| |
Summary | |
| |
| |
| |
Formatting output | |
| |
| |
Creating a table | |
| |
| |
Choosing specific properties in a specific order | |
| |
| |
Controlling the way the table displays | |
| |
| |
Creating a list | |
| |
| |
Choosing properties by name | |
| |
| |
Choosing properties by wildcard | |
| |
| |
Creating a wide display | |
| |
| |
Using the -AutoSize parameter to configure the output | |
| |
| |
Customizing the Format-Wide output | |
| |
| |
Creating an output grid | |
| |
| |
Sorting output by using the column buttons | |
| |
| |
Filtering output by using the filter box | |
| |
| |
Summary | |
| |
| |
| |
Storing output | |
| |
| |
Storing data in text files | |
| |
| |
Redirect and append | |
| |
| |
Redirect and overwrite | |
| |
| |
Controlling the text file | |
| |
| |
Storing data in .csv files | |
| |
| |
No type information | |
| |
| |
Using type information | |
| |
| |
Storing data in XML | |
| |
| |
The problem with complex objects | |
| |
| |
Using XML to store complex objects | |
| |
| |
Summary | |
| |
| |
| |
Leveraging Windows PowerShell providers | |
| |
| |
Understanding Windows PowerShell providers | |
| |
| |
Understanding the Alias provider | |
| |
| |
Understanding the Certificate provider | |
| |
| |
Understanding the Environment provider | |
| |
| |
Understanding the File System provider | |
| |
| |
Understanding the Function provider | |
| |
| |
Understanding the Registry provider | |
| |
| |
Understanding the Variable provider | |
| |
| |
Summary | |
| |
| |
| |
Using Windows PowerShell remoting | |
| |
| |
Using Windows PowerShell remoting | |
| |
| |
Classic remoting | |
| |
| |
Configuring Windows PowerShell remoting | |
| |
| |
Running commands | |
| |
| |
Creating a persisted connection | |
| |
| |
Troubleshooting Windows PowerShell remoting | |
| |
| |
Summary | |
| |
| |
| |
Using WMI | |
| |
| |
Understanding the WMI Model | |
| |
| |
Working with objects and namespaces | |
| |
| |
Listing WMI providers | |
| |
| |
Working with WMI classes | |
| |
| |
Querying WMI: The basics | |
| |
| |
Tell me everything about everything | |
| |
| |
Tell me selected things about everything | |
| |
| |
Tell me everything about some things | |
| |
| |
Tell me selected things about some things | |
| |
| |
Summary | |
| |
| |
| |
Using CIM | |
| |
| |
Using CIM cmdlets to explore WMI classes | |
| |
| |
Using the classname parameter | |
| |
| |
Finding WMI class methods | |
| |
| |
Filtering classes by qualifier | |
| |
| |
Reducing returned properties and instances | |
| |
| |
Cleaning up output from the command | |
| |
| |
Working with associations | |
| |
| |
Summary | |
| |
| |
| |
Using the Windows PowerShell ISE | |
| |
| |
Running the Windows PowerShell ISE | |
| |
| |
Navigating the Windows PowerShell ISE | |
| |
| |
Working with the Script pane | |
| |
| |
Tab expansion and Intellisense | |
| |
| |
Working with Windows PowerShell ISE snippets | |
| |
| |
Using Windows PowerShell ISE snippets to create code | |
| |
| |
Creating new Windows PowerShell ISE snippets | |
| |
| |
Removing user-defined Windows PowerShell ISE snippets | |
| |
| |
Summary | |
| |
| |
| |
Using Windows PowerShell scripts | |
| |
| |
Why write Windows PowerShell scripts? | |
| |
| |
Scripting fundamentals | |
| |
| |
Running Windows PowerShell scripts | |
| |
| |
Enabling Windows PowerShell scripting support | |
| |
| |
Transitioning from command line to script | |
| |
| |
Running Windows PowerShell scripts | |
| |
| |
Understanding variables and constants | |
| |
| |
Using the While statement | |
| |
| |
Constructing the While statement | |
| |
| |
A practical example of using the While statement | |
| |
| |
Using special features of Windows PowerShell | |
| |
| |
Using the Do…While statement | |
| |
| |
Using the range operator | |
| |
| |
Operating over an array | |
| |
| |
Casting to ASCII values | |
| |
| |
Using the Do…Until statement | |
| |
| |
Using the Windows PowerShell Do…Loop statement | |
| |
| |
Using the For statement | |
| |
| |
Creating a For…Loop | |
| |
| |
Using the ForEach statement | |
| |
| |
Exiting the ForEach statement early | |
| |
| |
Using the If statement | |
| |
| |
Using assignment and comparison operators | |
| |
| |
Evaluating multiple conditions | |
| |
| |
Using the Switch statement | |
| |
| |
Using the basic Switch statement | |
| |
| |
Controlling matching behavior | |
| |
| |
Summary | |
| |
| |
| |
Working with functions | |
| |
| |
Understanding functions | |
| |
| |
Using a type constraint | |
| |
| |
Using multiple input parameters | |
| |
| |
Using functions to encapsulate business logic | |
| |
| |
Using functions to provide ease of modification | |
| |
| |
Summary | |
| |
| |
| |
Debugging scripts | |
| |
| |
Understanding debugging in Windows PowerShell | |
| |
| |
Debugging the script | |
| |
| |
Setting breakpoints | |
| |
| |
Setting a breakpoint on a line number | |
| |
| |
Setting a breakpoint on a variable | |
| |
| |
Setting a breakpoint on a command | |
| |
| |
Responding to breakpoints | |
| |
| |
Listing breakpoints | |
| |
| |
Enabling and disabling breakpoints | |
| |
| |
Deleting breakpoints | |
| |
| |
Summary | |
| |
| |
| |
Handling errors | |
| |
| |
Handling missing parameters | |
| |
| |
Creating a default value for the parameter | |
| |
| |
Making the parameter mandatory | |
| |
| |
Limiting choices | |
| |
| |
Using PromptForChoice to limit selections | |
| |
| |
Using Test-Connection to identify accessible computers | |
| |
| |
Using the contains operator to examine contents of an array | |
| |
| |
Handling missing rights | |
| |
| |
Attempting and failing | |
| |
| |
Checking for rights and exiting gracefully | |
| |
| |
Using Try/Catch/Finally | |
| |
| |
Summary | |
| |
| |
Appendix A Windows PowerShell FAQ | |
| |
| |
Appendix B Windows PowerShell 3.0 coding conventions | |
| |
| |
General script construction | |
| |
| |
Include functions in the script that uses the functions | |
| |
| |
Use full cmdlet names and full parameter names | |
| |
| |
Use Get-Item to convert path strings to rich types | |
| |
| |
General script readability | |
| |
| |
Formatting your code | |
| |
| |
Working with functions | |
| |
| |
Creating template files | |
| |
| |
Writing your own functions | |
| |
| |
Variables, constants, and naming | |
| |
| |
Index | |