Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Windows PowerShell 3.0 First Steps
Dedication
Foreword
Introduction
System Requirements
Hardware Requirements
Software Requirements
Acknowledgments
Support & Feedback
Errata
We Want to Hear from You
Stay in Touch
1. Overview of Windows PowerShell 3.0
Understanding Windows PowerShell
Working with Windows PowerShell
Security issues with Windows PowerShell
Running as a non-elevated user
Launching Windows PowerShell with administrator rights
Using Windows PowerShell cmdlets
The most common verb: Get
Finding process information
Identifying installed Windows hotfixes
Getting detailed service information
Identifying installed network adapters
Retrieving detected network connection profiles
Getting the current culture settings
Finding the current date and time
Generating a random number
Supplying options for cmdlets
Using single parameters
Finding specific types of hotfixes
Finding specific processes
Generating random numbers in a range
Introduction to parameter sets
Generating a certain number of random numbers
Using command-line utilities
Working with Help options
Summary
2. Using Windows PowerShell cmdlets
Understanding the basics of cmdlets
Common Windows PowerShell parameters
Using the Verbose parameter to provide additional information
Using the ErrorAction parameter to hide errors
Starting the Windows PowerShell transcript
Stopping and reviewing the Windows PowerShell transcript
Searching the Help topics
Using the Get-Help cmdlet
Paging the Help output
Using the Get-Help cmdlet to search for Windows PowerShell cmdlets
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
3. 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
4. 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
5. 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
6. Leveraging Windows PowerShell providers
Understanding Windows PowerShell providers
Understanding the Alias provider
Understanding the Certificate provider
Searching for specific certificates
Finding expiring certificates
Understanding the Environment provider
Understanding the File System provider
Understanding the Function provider
Understanding the Registry provider
The two registry drives
Retrieving registry values
Creating new registry keys
The short way to create a new registry key
Setting the default value for the key
Using New-Item to create and assign a value
Modifying the value of a registry property value
Dealing with a missing registry property value
Understanding the Variable provider
Summary
7. Using Windows PowerShell remoting
Using Windows PowerShell remoting
Classic remoting
Configuring Windows PowerShell remoting
Running commands
Running a single Windows PowerShell command
Running a single command against multiple computers
Creating a persisted connection
Troubleshooting Windows PowerShell remoting
Summary
8. 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
9. Using CIM
Using CIM cmdlets to explore WMI classes
Using the classname parameter
Finding WMI class methods
Filtering classes by qualifier
Retrieving WMI instances
Reducing returned properties and instances
Cleaning up output from the command
Working with associations
Summary
10. 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
11. 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 variables
Using the While statement
Constructing the While statement
Understanding expanding strings
Understanding literal strings
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
The Do…While and Do…Until statements always run once
The While statement is used to prevent unwanted execution
Using the For statement
Creating a For…Loop
Using the ForEach statement
Using the ForEach statement from the Windows PowerShell console
Exiting the ForEach statement early
Using the Break statement
Using the Exit statement
Using the If statement
Using assignment and comparison operators
Evaluating multiple conditions
Using the Switch statement
Using the basic Switch statement
Defining the Default condition
Understanding matching
Evaluating an array
Controlling matching behavior
Summary
12. 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
13. 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
14. Handling errors
Handling missing parameters
Creating a default value for the parameter
Detecting the missing value and assigning it in the script
Assigning the value in the Param statement
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
A. Windows PowerShell FAQ
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
Understanding the use of aliases
If you must use an alias, use only canonical aliases in a script
Always use the Description property when creating an alias
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
About the Author
Copyright
← Prev
Back
Next →
← Prev
Back
Next →