Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Windows PowerShellâ„¢ 3.0 Step by Step
Dedication
Foreword
Introduction
Who should read this book
Assumptions
Who should not read this book
Organization of this book
Finding your best starting point in this book
Conventions and features in this book
System requirements
Code samples
Installing the code samples
Acknowledgments
Errata and book support
We want to hear from you
Stay in touch
1. Overview of Windows PowerShell 3.0
Understanding Windows PowerShell
Using cmdlets
Installing Windows PowerShell
Deploying Windows PowerShell to down-level operating systems
Using command-line utilities
Security issues with Windows PowerShell
Controlling execution of PowerShell cmdlets
Confirming actions
Suspending confirmation of cmdlets
Working with Windows PowerShell
Accessing Windows PowerShell
Configuring the Windows PowerShell console
Supplying options for cmdlets
Working with the help options
Exploring commands: step-by-step exercises
Chapter 1 quick reference
2. Using Windows PowerShell Cmdlets
Understanding the basics of cmdlets
Using the Get-ChildItem cmdlet
Obtaining a directory listing
Formatting a directory listing using the Format-List cmdlet
Using the Format-Wide cmdlet
Formatting a directory listing using Format-Table
Formatting output with Out-GridView
Leveraging the power of Get-Command
Searching for cmdlets using wildcard characters
Using the Get-Member cmdlet
Using the Get-Member cmdlet to examine properties and methods
Using the New-Object cmdlet
Creating and Using the wshShell Object
Using the Show-Command cmdlet
Windows PowerShell cmdlet naming helps you learn
Windows PowerShell verb grouping
Windows PowerShell verb distribution
Creating a Windows PowerShell profile
Finding all aliases for a particular object
Working with cmdlets: step-by-step exercises
Chapter 2 quick reference
3. Understanding and Using PowerShell Providers
Understanding PowerShell providers
Understanding the alias provider
Understanding the certificate provider
Searching for specific certificates
Finding expiring certificates
Understanding the environment provider
Understanding the filesystem provider
Understanding the function provider
Using the registry provider to manage the Windows registry
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
The short way to change a registry property value
Dealing with a missing registry property
Understanding the variable provider
Exploring PowerShell providers: step-by-step exercises
Chapter 3 quick reference
4. Using PowerShell Remoting and Jobs
Understanding Windows PowerShell remoting
Classic remoting
WinRM
Creating a remote Windows PowerShell session
Running a single Windows PowerShell command
Using Windows PowerShell jobs
Using Windows PowerShell remoting: step-by-step exercises
Chapter 4 quick reference
5. Using 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
Use of variables
Use of constants
Using the While statement
Constructing the While statement in PowerShell
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
Comparing the PowerShell Do...Until statement with VBScript
Using the Windows PowerShell Do statement
The Do...While and Do...Until statements always run once
The While statement is used to prevent unwanted execution
The For statement
Using the For statement
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
The If statement
Using assignment and comparison operators
Evaluating multiple conditions
The Switch statement
Using the Switch statement
Defining the default condition
Understanding matching with the Switch statement
Evaluating an array
Controlling matching behavior
Creating multiple folders: step-by-step exercises
Chapter 5 quick reference
6. Working with Functions
Understanding functions
Using functions to provide ease of code reuse
Including functions in the Windows PowerShell environment
Using dot-sourcing
Using dot-sourced functions
Adding help for functions
Using a here-string object for help
Using two input parameters
Using a type constraint in a function
Using more than two input parameters
Use of functions to encapsulate business logic
Use of functions to provide ease of modification
Understanding filters
Creating a function: step-by-step exercises
Chapter 6 quick reference
7. Creating Advanced Functions and Modules
The [cmdletbinding] attribute
Easy verbose messages
Automatic parameter checks
Adding support for the -whatif parameter
Adding support for the -confirm parameter
Specifying the default parameter set
The parameter attribute
The mandatory parameter property
The position parameter property
The ParameterSetName parameter property
The ValueFromPipeline property
The HelpMessage property
Understanding modules
Locating and loading modules
Listing available modules
Loading modules
Installing modules
Creating a per-user Modules folder
Working with the $modulePath variable
Creating a module drive
Checking for module dependencies
Using a module from a share
Creating a module
Creating an advanced function: step-by-step exercises
Chapter 7 quick reference
8. 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
Using the Commands add-on: step-by-step exercises
Chapter 8 quick reference
9. Working with Windows PowerShell Profiles
Six Different PowerShell profiles
Understanding the six different Windows PowerShell profiles
Examining the $profile variable
Unraveling the different profiles
Using the $profile variable to refer to more than the current host
Determining whether a specific profile exists
Creating a new profile
Design considerations for profiles
Using one or more profiles
Using the All Users, All Hosts profile
Using your own file
Grouping similar functionality into a module
Where to store the profile module
Creating a profile: step-by-step exercises
Chapter 9 quick reference
10. Using WMI
Understanding the WMI model
Working with objects and namespaces
Listing WMI providers
Working with WMI classes
Querying WMI
Obtaining service information: step-by-step exercises
Chapter 10 quick reference
11. Querying WMI
Alternate ways to connect to WMI
Selective data from all instances
Selecting multiple properties
Choosing specific instances
Utilizing an operator
Where is the where?
Shortening the syntax
Using the -property parameter
Using the -filter parameter
Working with software: step-by-step exercises
Chapter 11 quick reference
12. Remoting WMI
Using WMI against remote systems
Supplying alternate credentials for the remote connection
Storing the credentials for a remote connection
Using Windows PowerShell remoting to run WMI
Using CIM classes to query WMI classes
Using CIM to query remote WMI data
Working with remote results
Reducing data via Windows PowerShell parameters
Running WMI jobs
Using Windows PowerShell remoting and WMI: Step-by-step exercises
Chapter 12 quick reference
13. Calling WMI Methods on WMI Classes
Using WMI cmdlets to execute instance methods
Using the terminate method directly
Using the Invoke-WmiMethod cmdlet
Using the [wmi] type accelerator
Using WMI to work with static methods
Executing instance methods: step-by-step exercises
Chapter 13 quick reference
14. Using the CIM Cmdlets
Using the 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
Retrieving WMI instances: step-by-step exercises
Chapter 14 quick reference
15. Working with Active Directory
Creating objects in Active Directory
Creating an OU
ADSI providers
LDAP names
Binding
Creating users
What is user account control?
Working with users
General user information
Creating the address page
Deleting users
Creating multiple organizational units: step-by-step exercises
Chapter 15 quick reference
16. Working with the AD DS Module
Understanding the Active Directory module
Installing the Active Directory module
Getting started with the Active Directory module
Using the Active Directory module
Finding the FSMO role holders
Discovering Active Directory
Renaming Active Directory sites
Managing users
Creating a user
Finding and unlocking Active Directory user accounts
Finding disabled users
Finding unused user accounts
Updating Active Directory objects: step-by-step exercises
Chapter 16 quick reference
17. Deploying Active Directory with Windows Server 2012
Using the Active Directory module to deploy a new forest
Adding a new domain controller to an existing domain
Adding a read-only domain controller
Domain controller prerequisites: step-by-step exercises
Chapter 17 quick reference
18. Debugging Scripts
Understanding debugging in Windows PowerShell
Understanding three different types of errors
Working with syntax errors
Working with run-time errors
Working with logic errors
Using the Set-PSDebug cmdlet
Tracing the script
Working with trace level 1
Working with trace level 2
Stepping through the script
Enabling strict mode
Using Set-PSDebug -Strict
Using the Set-StrictMode cmdlet
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
Debugging a function: step-by-step exercises
Chapter 18 quick reference
19. Handling Errors
Handling missing parameters
Creating a default value for a parameter
Detecting a missing value and assigning it in the script
Assigning a value in the param statement
Making the parameter mandatory
Limiting choices
Using PromptForChoice to limit selections
Using Test-Connection to identify computer connectivity
Using the -contains operator to examine contents of an array
Using the -contains operator to test for properties
Handling missing rights
Attempt and fail
Checking for rights and exiting gracefully
Handling missing WMI providers
Incorrect data types
Out-of-bounds errors
Using a boundary-checking function
Placing limits on the parameter
Using Try...Catch...Finally
Catching multiple errors
Using PromptForChoice to limit selections: Step-by-step exercises
Chapter 19 quick reference
20. Managing Exchange Server
Exploring the Exchange 2010 cmdlets
Working with remote Exchange servers
Configuring recipient settings
Creating the user and the mailbox
Reporting user settings
Managing storage settings
Examining the mailbox database
Managing the mailbox database
Managing Exchange logging
Managing auditing
Parsing the audit XML file
Creating user accounts: step-by-step exercises
Chapter 20 quick reference
A. Windows PowerShell Core Cmdlets
B. Windows PowerShell Module Coverage
C. Windows PowerShell Cmdlet Naming
D. Windows PowerShell FAQ
E. Useful WMI Classes
F. Basic Troubleshooting Tips
G. General PowerShell Scripting Guidelines
General script construction
Include functions in the script that uses the function
Use full cmdlet names and full parameter names
Understanding the use of aliases
If you must use an alias, only use 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
Functions
Variables, constants, and naming
H. About the Author
Index
About the Author
Copyright
← Prev
Back
Next →
← Prev
Back
Next →