Copyright
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email:
orders@manning.com2018 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
| Manning Publications Co.20 Baldwin RoadPO Box 761Shelter Island, NY 11964 |
Development editor: Frances LefkowitzTechnical development editor: James BerkenbileProject editor: Janet VailCopyeditor: Tiffany TaylorProofreader: Alyson BrenerTechnical proofreader: James BerkenbileTypesetter: Dennis DalinnikCover designer: Leslie Haimes
ISBN: 9781617295096
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 EBM 22 21 20 19 18 17
Brief Table of Contents
Table of Contents
Preface
Way back in 2012, some six years after Windows PowerShell was born, Jeff and I wrote Learn Windows PowerShell Toolmaking in a Month of Lunches. The word toolmaking was important to us. My first job out of high school was working as an aircraft mechanic, and one of the first trades I was exposed to was the machine shop. Imagine a hot, humid warehouse in Norfolk, Virginia, full of noisy machines chipping away at chunks of metal. Machinists would spend hours, sometimes, setting up a milling machine with various tools and diesfancy drill and router bits, basicallythat would carve a block of metal into a useful aircraft part. You went home with your hair full of metal chips, your skin covered in lubricants, and your ears ringing from all the noise. I swore I didnt want to become one of these tool users. Of course someone has to wield the tools, and theres nothing wrong with it. I just didnt want it to be me.
But tucked away at the back of the warehouse was a small, enclosed, air-conditioned office. The men and women there wore dress shirts and sat in front of computers all day, designing the tools and dies the machinists used. These tool and die makers, or toolmakers, got paid more, had a better work environment, and generally hadin my post-teenager viewbetter lives. I promised myself that in order to escape my personal hellhole of a workplace, Id work hard to become one of them.
That attitude served me well after I shifted into IT a few years later. As a LAN manager for a Bell Atlantic subsidiary (its part of Verizon, now), my help desk and Tier 2 guys brought me plenty of problems to solve, and my solution almost every time was to write a script for them. That way, those tool users could solve problems on their own, and I could act as a force multiplier, enabling them to solve problems rather than spending all my time solving them. Making tools for others is, in many ways, the highest IT calling for me, and Ive devoted significant effort to making sure I was always in that kind of enabler position. Plus, I dont get calls from users or late-night pagesbonus!
Candidly, this books titleLearn PowerShell Scripting in a Month of Lunchesis a total search engine optimization ploy. People search for PowerShell Scripting a lot more than PowerShell Toolmaking. But now that you have the book in your hands, physically or digitally, know that Jeff and I are going to try and make you a toolmaker, not just a scripter. If youre not sure what the difference is, dont worryitll become clearer as you go. Weve rewritten this entire book, dropped content that strayed away from toolmaking, and added contentlike automated testing, publishing your code, and so onthat sits firmly within the realm of toolmaking. Weve taken everything weve learned in the last four or five years and brought it to this new title. Our goal is to make you the best toolmaker you can possibly be, to make you a force multiplier within your organization, and to put your career on the firmest footing possible. Thanks for joining us, and enjoy the ride.
D ON J ONES
Acknowledgments
Books simply dont write, edit, and publish themselves. We would like to thank everyone at Manning Publications who decided to take a chance on a very different kind of book for Windows PowerShell, and who worked so hard to make this book happen. Wed like to acknowledge our peer reviewers who kept us honest, including Bruno Sonnino, Edul Chikhliwala, Foster Haines, Jan Vinterberg, Justin Coulston, Reka Horvath, Roman Levchenko, and Shankar Swamy.
Wed also like to extend a big thank you to everyone who purchased a MEAP edition, which reflects your confidence in the quality of our work. We hope we meet your standards.
Finally, a sincere thank you to the entire PowerShell community. You are a spirited, hard-driving bunch who keep us motivated and energized.
About this Book
In this book, were pretty careful to walk you through everything you need to know about PowerShell scripting and toolmaking, beginning with its important. But there are a few administrative details we should get out of the way:
- Be prepared to follow along. If a chapter has a hands-on exercise, theres a reason for thatits good for your brain to complete the exercise. Well discuss this a bit more in .
- Read the chapters in order. Again, explains why; for now, know that its in your best interests to follow the narrative weve constructed. Well expose you to specific problems so youll know more about why things are happening, and well also show you how to script.
- Download the code. Manning hosts a zip file with this books sample code, and we suggest you download it from www.manning.com/books/learn-powershell-scripting-in-a-month-of-lunches. Follow along with the code open in an editor, if possible, because itll look a great deal nicer than what we can print in a book.
Join the community
We suggest that you look around and find a community of active PowerShell enthusiasts to become your new best friends. Youre definitely going to run into problems as you pursue your new scripting avocation, and colleagues are the best source for help. Find a local user group, or even make a website like PowerShell.org a regular stopping place. This will take effort on your part, and its far easier to ignore this important aspect of your career. Dont.
Book forum
Purchase of