PowerShell Deep Dives
Edited by Jeffery Hicks, Richard Siddaway, Oisín Grehan, and Aleksandar Nikolić
  • July 2013
  • ISBN 9781617291319
  • 464 pages
  • printed in black & white

Here's your chance to learn from the best in the business. PowerShell Deep Dives is a trove of essential techniques, practical guidance, and the expert insights you earn only through years of experience. Editors Jeffery Hicks, Richard Siddaway, Oisin Grehan, and Aleksandar Nikolić hand-picked the 28 chapters in the book's four parts: Administration, Scripting, Development, and Platforms.

Table of Contents show full



about this book

about Save the Children

Part 1 PowerShell administration

1. Diagnosing and troubleshooting PowerShell remoting

1.1. Diagnostics examples

1.2. A perfect remoting connection

1.3. Connection problem: Blocked port

1.4. Connection problem: No permissions

1.5. Connection problem: Untrusted host

1.6. Summary

2. CIM sessions

2.1. WMI

2.2. CIM cmdlets

2.3. Using CIM sessions

2.4. CIM session options

2.5. Summary

3. Collecting and analyzing performance counter data

3.1. Windows Performance Logs and Alerts

3.2. Enumerating the counter groups

3.3. Finding the right counters

3.4. Accessing the counters' data

3.5. Using jobs for long-running tasks

3.6. Saving the performance data to a file

3.7. Manipulating stored performance data from a file

3.8. Summary

4. TCP port communications with PowerShell

4.1. Testing for an open port

4.2. Sending and receiving data

4.3. LDAP port communications

4.4. Creating an Echo server

4.5. Summary

5. Managing systems through a keyhole

5.1. PowerShell remoting

5.2. PowerShell Web Access

5.3. Summary

6. Using PowerShell to audit user logon events

6.1. Event log basics

6.2. Querying the event logs with PowerShell

6.3. Auditing logon failures

6.4. Auditing logon type and authentication protocol

6.5. Auditing Active Directory user-account lockout events

6.6. Summary

7. Managing and administering a certification authority database with PowerShell

7.1. Existing tools

7.2. Querying the CA database

7.3. Advanced administration of the CA database

7.4. Summary

8. Using PowerShell to reduce Active Directory token bloat

8.1. SIDs 101

8.2. Where does the SID history come from?

8.3. The solution

8.4. The script

8.5. Listing domain SIDs and trusts

8.6. The challenge

8.7. PowerShell options

8.8. The script solution

8.9. Summary

Part 2 PowerShell scripting

9. The 10 PowerShell scripting commandments

9.1. Constructing a sound function

9.2. Output

9.3. Parameters

9.4. Example: finding duplicate files

9.5. Extra tricks for file parameters

9.6. Write code for another person to read

9.7. Summary

10. Avoiding the pipeline

10.1. Requirements

10.2. Rules of engagement

10.3. Filtering objects sooner

10.4. Providers and filtering parameters

10.5. Using regular expressions

10.6. Using member enumeration

10.7. Summary

11. A template for handling and reporting errors

11.1. Using preference variables: $ErrorActionPreference

11.2. Using structured error handling: try/catch/finally

11.3. Using $Error and InvocationInfo objects

11.4. Handling custom business-logic errors with throw and try

11.5. Final template

11.6. Summary

12. Tips and tricks for creating complex or advanced HTML reports with PowerShell

12.1. Standard ConvertTo-HTML output

12.2. Script parameters and help

12.3. ConvertTo-HTML’s -Fragment parameter

12.4. Using a PowerShell here-string to create the HTML header

12.5. Encoding an image into the HTML report

12.6. Adding charts to the report

12.7. Preparing the data for the report

12.8. Differentiating report data with color

12.9. Final steps

12.10. Summary

13. Using and "abusing" dynamic parameters

13.1. Practical applications

13.2. Summary

14. PowerShell type formatting

14.1. Creating a formatting file

14.2. View definitions

14.3. Defining table headers

14.4. Conditional row entries

14.5. Grouping

14.6. Custom controls

14.7. Putting it together

14.8. Loading formatting data

14.9. Summary

15. Scalable scripting for large data sets: pipeline and database techniques

15.1. The stream and the water balloon

15.2. Streams and water balloons in PowerShell scripts

15.3. Making it real: streaming over data in complex realistic tasks

15.4. If it quacks like a database…​

15.5. Summary

16. Building your own WMI-based cmdlets

16.1. Discovering WMI-based cmdlets

16.2. Creating a WMI-based cmdlet

16.3. Using a WMI-based cmdlet

16.4. Adding extra filter parameters

16.5. Creating cmdlets from WMI methods

16.6. Summary

17. Turning command-line tools into PowerShell tools

17.1. Requirements

17.2. Conversion techniques

17.3. A practical example

17.4. Summary

Part 3 PowerShell for developers

18. Using Source Control Software with PowerShell

18.1. Requirements

18.2. When to use source control

18.3. Introduction to Mercurial

18.4. Common source control operations

18.5. Using Mercurial from PowerShell

18.6. Working with Mercurial in teams

18.7. Summary

19. Inline .NET code

19.1. .NET class for output

19.2. .NET class with methods

19.3. Summary

20. PowerShell and XML: better together

20.1. What is XML?

20.2. XML in .NET and PowerShell

20.3. Adapted objects and XMLNodeAdapter

20.4. Read and write XML documents

20.5. Special XML cases

20.6. Summary

21. Adding automatic remoting to advanced functions and cmdlets

21.1. Delivering economic value

21.2. An automatic remoting example

21.3. Defining the user experience

21.4. Implementing your solution

21.5. Making it more standard

21.6. Dealing with the real world and gotchas

21.7. Summary

22. Taming software builds (and other complicated processes) with psake

22.1. Building software

22.2. Introducing psake

22.3. psake build scripts

22.4. Running the build script

22.5. Building Visual Studio projects

22.6. Using PowerShell in psake tasks

22.7. Configuring the build with properties

22.8. Managing psake script growth

22.9. Summary

Part 4 PowerShell platforms

23. PowerShell and the SQL Server provider

23.1. Requirements

23.2. Introduction to the SQL Server provider

23.3. Using the SQL Server provider

23.4. Examples of using the SQL Server provider

23.5. Getting a count of databases in an instance

23.6. Finding a table in many databases

23.7. Summary

24. Creating flexible subscriptions in SSRS

24.1. Understanding SSRS subscriptions

24.2. Environment settings

24.3. Requirements

24.4. Subscription in action

24.5. Summary

25. Inventory database table statistics using PowerShell and SQL Server Management Objects

25.1. Understanding SMO

25.2. Loading SMO

25.3. The Server object

25.4. Creating the inventory database using SMO

25.5. Creating the TableStats table using SMO

25.6. Resetting from previous runs

25.7. Gathering inventory data

25.8. Querying the data

25.9. Other ways to use the data

25.10. Summary

26. WSUS and PowerShell

26.1. WSUS server configuration and events

26.2. Automatic approval rules

26.3. Reporting in WSUS

26.4. Summary

27. Provisioning IIS web servers and sites with PowerShell

27.1. Rapid IIS deployment

27.2. Transferring website files and certificates

27.3. Enabling remote management for IIS Manager

27.4. Creating a load-balanced web farm

27.5. Creating an SSL website

27.6. Automating the process

27.7. Summary

28. Active Directory Group Management application

28.1. Requirements

28.2. Designing the UI

28.3. Handling database interactions

28.4. Writing the Active Directory modification script

28.5. Summary


About the Technology

PowerShell has permanently changed Windows administration. This powerful scripting and automation tool allows you to control virtually every aspect of Windows and most Microsoft servers like IIS and SQL Server.

About the book

PowerShell Deep Dives is a trove of essential techniques and practical guidance. It is rich with insights from experts who won them through years of experience. The book's 28 chapters, grouped in four parts (Administration, Scripting, Development, and Platforms), were hand-picked by four section editors: Jeffery Hicks, Richard Siddaway, Oisín Grehan, and Aleksandar Nikolić.

Whether you're just getting started with PowerShell or you already use it daily, you'll find yourself returning to this book over and over.

What's inside

  • Managing systems through a keyhole
  • The Ten Commandments of PowerShell scripting
  • Scalable scripting for large datasets
  • Adding automatic remoting
  • Provisioning web servers and websites automatically to IIS 8
  • And 23 more fantastic chapters

About the authors

Editors Jeffery Hicks, Richard Siddaway, Oisín Grehan, and Aleksandar Nikolić are joined by PowerShell experts Chris Bellée, Bartek Bielawski, Robert C. Cain, Jim Christopher, Adam Driscoll, Josh Gavant, Jason Helmick, Don Jones, Ashley McGlone, Jonathan Medd, Ben Miller, James O'Neill, Arnaud Petitjean, Vadims Podans, Karl Prosser, Boe Prox, Matthew Reynolds, Mike Robbins, Donabel Santos, Will Steele, Trevor Sullivan, and Jeff Wouters.

About Save the Children

SAVE THE CHILDREN works around the world and in the U.S. to make sure all girls and boys have a brighter future. The charity serves impoverished, marginalized and vulnerable children and families in 120 countries.

combo $49.99 pBook + eBook
eBook $39.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks