MicrosoftВ® Windows PowerShell(TM) Step By Step (Step By Step (Microsoft))
Ed Wilson
Microsoft
PUBLISHED BY Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond,Washington 98052-6399
© 2007 by Ed Wilson
ISBN: 9780735623958
All rights reserved.No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher.
Library of Congress Control Number: 2007924649
1 2 3 4 5 6 7 8 9 QWT 2 1 0 9 8 7
Distributed in Canada by H.B. Fenn and Company Ltd.
A CIP catalogue record for this book is available from the British Library.
Microsoft Press books are available through booksellers and distributors worldwide. For further information about international editions,contact your local Microsoft Corporation office or contact Microsoft Press International directly at fax (425) 936-7329. Visit our Web site at www.microsoft.com/mspress. Send comments to mspinput@microsoft.com.
Microsoft, Microsoft Press, Active Accessibility, Active Desktop, Active Directory, ActiveMovie, ActiveStore, ActiveSync, ActiveX, Age of Mythology, Authenticode, BackOffice, BizTalk, ClearType, DataTips, Developer Studio, Direct3D, DirectAnimation, DirectDraw, DirectInput, DirectMusic, DirectPlay, DirectShow, DirectSound, DirectX, Excel, FrontPage, IntelliMouse, IntelliSense, Internet Explorer, J/Direct, Jscript, Liquid Motion, MSDN, MS-DOS, Outlook, PivotChart, PivotTable, PowerPoint, Rushmore, SQL Server, Visual Basic, Visual C++, Visual FoxPro, Visual InterDev, Visual J++, Visual SourceSafe, Visual Studio, Win32, Win32s, Windows, Windows NT, Windows PowerShell, Windows Server, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.Other product and company names mentioned herein may be the trademarks of their respective owners.
The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred.
This book express the author’s views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book.
-
Acquisitions Editor: Martin DelRe
-
Developmental and Project Editor: Maureen Zimmerman
-
Editorial Production: P.M. Gordon Associates
-
Technical Reviewer: Bob Hogan; technical review services provided by Content Master, a member of CM Group, Ltd.
Body Part No. X13-68391
Dedication
To Teresa: my friend, my helper, and my muse.
About the Author
Ed Wilson is a senior consultant at Microsoft Corporation and a scripting expert. He is a Microsoft Certified Trainer who delivers immensely popular workshops world-wide on VBScript, WMI, and Windows PowerShell. He’s written more than a dozen books, including four on scripting, such as Microsoft VBScript Step by Step (Microsoft Press, 2006), and Microsoft Windows Scripting with WMI: Self-Paced Learning Guide (Microsoft Press, 2005). Ed holds more than 20 industry certifications, including the MCSE and CISSP.
Acknowledgments
Books of this length, or for that matter, even very short books, do not happen automatically- nor do they arrive in a vacuum. If the book being contemplated is about software that is not even released . . . dude, you are going to need some help. One of the cool things about writing more than a dozen books is that, through the years, I have developed a stable of friends (nice for a guy named Mr. Ed), loved ones, technical mentors, and coworkers who have all taken an interest in the writing process and have wanted to help out.
The number-one person . . . well, actually, there are several number-one persons that need thanking. The one I had better thank first is my wife, Teresa. This poor girl, an accountant by training, has become the de facto scripting expert in her company. Why, you may ask? Other than the fact that she is married to me and sees me walking around aimlessly from time to time, she has had the privilege of reading four books on scripting-not once, but many times. What about this book on Windows PowerShell? Well, she has read it at least three times. Of course, I would not dare say that if you find problems, it is her fault! No way!
There are several other number one-persons I need to thank. My agent, Claudette Moore of the Moore Literary Agency, for instance, needs thanking. If not for her efforts, my book never would have been published by Microsoft Press. She is also a good person to talk to when I need encouragement.
Another number-one person to thank is Martin DelRe, my acquisitions editor at MSPress. This guy is awesome! I love talking to him. He is such a believer in the power and message of scripting that he has devoted a sizable portion of his titles to scripting. It is very rare to deal with an acquisitions editor who is as knowledgeable about scripting, networking, and the like as is Martin. The best compliment I have ever received from an editor came from him. He said, “Your book looks good. I think I will take it home and read it this weekend.” My best friend didn’t even say that!
The other number-one person I need to think is Maureen Zimmerman. She worked so hard to keep the book on track, and I was in 14 different countries last year while writing the book. There were time zone issues, VPN issues, language barriers-language barriers, did I say? Yes. Not between me and Maureen, but between me and the keyboard in the concierge lounge in Vienna, or Munich, or London, or Sydney, or this place. . . . Do you know how hard it is to find the @ key while trying to use American input on a German keyboard? I ended up opening Notepad and typing every key on the silly thing until I found it . . . then I cut and pasted it. Hey, better than getting locked out of your e-mail.
This book had some awesome assistance from other people as well. First among them is Jit Banerjie, a consultant for Microsoft in Australia. Technically, I am his mentor. But I always learn more when talking to him than I think he ever learns from me. Whenever I would get stuck trying to figure out something in Windows PowerShell, I would type a quick e-mail to him . . . “Hey Jit! Help! I need to figure out how to do. . . . ” Sometimes it worked. Other times, well, he is on the other side of the world from me most of the time . . . unless I happen to be in Canberra, then I just show up at his door step looking hungry (his wife is a great cook).
Then there is the PowerShell Community Extension project. One of the awesome things that the Microsoft Windows PowerShell team did was to make PowerShell extensible. There is a guy named Keith Hill who is working with this project. He gave me permission (along with some of his other cohorts) to include the PSCX version 2.0 on the CD with this book. This is awesome! Interestingly enough, one of my other tech reviewers (on my first VBScript book) was Alex Angelopoulos, and wouldn’t you know it, he is working with the PSCX guys on extending Windows PowerShell. This is very cool. Then there were Oisin Grehan, Matt Hamilton, jachymko, Reinhard Lehrbaum, and Mark Maier, all of whom worked on this project, and without their permission, I would not have been able to include PSCX on the CD. If you ever see one of them, say thanks.
Bill Mell, MCSE, and Terry Lawson, MCSE, reviewed the labs for the book. They have been working with me since my book on Netmon many years ago.
I need to thank Dr. Tobias Weltner for allowing me to include the free version of his PowerShell IDE in my book. Every time I go to Germany, someone in one of my classes will ask me: “Do you know Dr. Weltner?” Now I can say, “Sure, he let me use his PowerShell IDE in my book!”
Then there is Ivan Giugni, the product manager for Power Gadgets. He was good enough to make sure I got the latest build of Power Gadgets for the book. Do you want to produce some impressive-looking output from Windows PowerShell? You need to use Power Gadgets. The scripting guys love Power Gadgets. The Windows PowerShell team love Power Gadgets-because they are cool.
I also need to thank Alexander Riedel from Sapien for allowing me to include a demo version of Primal Script 4.1 with my book. Primal Script has always been an awesome script editor, and now with support for Windows PowerShell, it is even better.
I need to thank the Microsoft Scripting Guys: Greg Stemp, Dean Tsaltas, and Peter Costantini for allowing me to include their VBScript to Windows PowerShell conversion guide as Appendix C. This is an awesome document and represents hundreds of hours of work. I included it in my book because I wanted to always have it close by. Okay, you are looking at me strangely. You mean you don’t always carry a copy of a scripting book around with you? Hmmmmm.
One other person I need to thank is Ben Pearce, who is a supportability engineer for Microsoft in the United Kingdom. He created the Cheat Sheet V1.0, which I have included in the supplemental resources folder on the CD. This is a beautiful cheat sheet, which I have printed out, laminated, and posted next to my computer in my office at home. I think you will like it as well.
Категории