ebook img

Windows PowerShell TFM PDF

852 Pages·2014·27.875 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Windows PowerShell TFM

831 Latour Ct Ste B2 | Napa, CA 94558 www.SAPIENPress.com This book is dedicated to everyone whose hard work has made it possible: to Jason and Mike for their writing and research; to the gang at HK Communication for their expert editing; to Back of the Book for their accurate indexing; to David, June, Alex and Ferdinand for their constant and tireless reviewing; and to Maricela for her patience and diligence in laying out the book and for her creative and beautiful cover art. - SAPIEN Press, Publisher Visit www.ScriptingAnswers.com for answers to all your PowerShell questions! You can also check out the SAPIEN Technologies blog at http://blog.sapien.com, where you’ll find the latest scripting news, PowerShell tips, and much more. Drop by and subscribe today! Please post any errors that you find to the following web page http://www.sapien.com/errata Forward When I learned that SAPIEN was undertaking a massive rewrite and re-organization of Windows PowerShell: TFM, I was somewhat nervous. After all, the first three editions by Jeff Hicks and myself were literally the first PowerShell books ever published for their respective versions of the product—I obviously was fond of them! But it was time for an update. Indeed, it was time for a re-do, to a certain extent, because since 2006 we’d learned a lot about how people learned PowerShell and the book needed to reflect newer approaches and the expanding audience. Unfortunately, neither Jeff nor I could find time in our schedules to do the work. I was delighted when Jason and Mike stepped in. Both have rocketed to the forefront of the PowerShell community in a very short time and they’re both great to work with— very knowledgeable and excellent at explaining things in approachable, plain-English terms. Jason has become my right-hand man in running PowerShell.org, Mike was a first-place winner in PowerShell.org’s first Scripting Games (after Microsoft handed them off to us)…who better to work on this next generation of TFM? And I can still say that I had a bit of a hand in things. Jason and Mike kept a lot of the original material, but reworked it into their own style and of course updated it for the newest PowerShell ™versions. Jason’s a big fan of my instructional design approach and this is probably the first TFM that really reflects those principles. And certainly, I’ll always have a soft spot in my heart for this book and the entire TFM series. While this might not be the last PowerShell book you ever buy, I know it’ll be one that gets heavily dog-eared (or whatever the electronic equivalent is, if you’re using an e- book) from constant reference. And, my gratitude to Mike and Jason for upholding the fine tradition that Jeff and I started more than six years ago. Don Jones When Don and I set out years ago to write the PowerShell TFM books, we had no idea that we were setting a standard for tech books. I was always glad to hear how much the books had helped people out and that they enjoyed, even appreciated, the TFM style and approach. Now, it is time for Jason and Mike to take the baton and lead the pack around the next corner. If you know, or ever meet Jason and Mike, you might think them an odd pairing. Perhaps no different than Don and I, but it works. As a team, they have your back with this PowerShell thing. Their experiences as IT Pros, trainers, scripters, and community leaders make them ideal candidates to carry the TFM baton. Don and I always wanted the TFM brand to be the books you kept at your desk and this book will be no exception. Enough of the reminiscing. It is time for you to dig in. Jason and Mike are waiting for you. Jeff Hicks About the Authors Jason Helmick is Senior Technologist at Concentrated Tech. His IT career spans more than 25 years of enterprise consulting on a variety of technologies, with a focus on strategic IT business planning. He’s a highly successful IT author, columnist, lecturer, and instructor, specializing in automation practices for the IT pro. Jason is a leader in the IT professional community, and serves as board member and COO/CFO of PowerShell.Org and is a Windows PowerShell MVP. Jason’s publications include Learn Windows IIS in a Month of Lunches, and he has contributed to numerous industry publications and periodicals, including PowerShell Deep Dives, Microsoft TechNet and TechTarget Magazine. He is a sought-after speaker at numerous technical conferences and symposia, and has been a featured presenter in the Microsoft Virtual Academy. He can be contacted on Twitter: @theJasonHelmick . Mike F Robbins is a Senior Systems Engineer with 20 years of professional experience as an IT Pro. During his career, Mike has provided enterprise computing solutions for educational, financial, healthcare, and manufacturing customers. He’s a PowerShell MVP and self-proclaimed PowerShell evangelist who uses PowerShell on a daily basis to administer and manage Windows Server, Hyper-V, SQL Server, Active Directory, Exchange, IIS, SharePoint, Terminal Services, EqualLogic Storage Area Networks, AppAssure, and Backup Exec. Mike is the winner of the advanced category in the 2013 PowerShell Scripting Games. He has written guest blog articles for the Hey, Scripting Guy! Blog, PowerShell.org, PowerShell Magazine, and is a contributing author of a chapter in the PowerShell Deep Dives book. Mike is the leader and co-founder of the Mississippi PowerShell User Group. Mike is also a frequent speaker at PowerShell and SQL Saturday technology events. He blogs at mikefrobbins.com and can be found on twitter @mikefrobbins. Chapter 1 Before you start Why PowerShell, why now? When PowerShell released, the only publicly known software to embed its management with PowerShell was the upcoming release of Microsoft Exchange Server 2007. Today, many platforms are integrating their management through the use of PowerShell—and the list continues to grow. Here are a few reasons why you should learn to use PowerShell: 1. It’s not going away. 2. Most Microsoft products use it. 3. You can’t do everything from the GUI. 4. It can make your life easier through automation. 5. Microsoft certification exams contain PowerShell questions. 6. If you don’t learn it, someone else will. What Is PowerShell and Why Should I Care? Administrators of UNIX and Linux systems (collectively referred to as “*nix” throughout this book) have always had the luxury of administrative scripting and automation. In fact, most *nix operating systems are built on a command-line interface (CLI). The graphical operating environment of *nix systems—often the “X Windows” environment—is itself a type of shell; the operating system is fully functional without this graphical interface. This presents a powerful combination. Since the operating system is typically built from the command-line, there isn’t anything you can’t do from an administrative sense, from the command-line. That’s why *nix admins are so fond of scripting languages like Python and Perl—they can accomplish real administration tasks with them. Windows, however, has always been different. When a Microsoft product group sat down to develop a new feature—say, the Windows DNS Server software—they had certain tasks that were simply required. First and foremost, of course, was the actual product functionality—such as the DNS Server service, the bit of the software that actually performs as a DNS server. Some form of management interface was also required and the Windows Common Engineering Criteria specified that the minimum management interface was a Microsoft Management Console (MMC) snap-in—that is, a graphical administrative interface. If they had extra time, the product team might create a Windows Management Instrumentation (WMI) provider, connecting their product to WMI, or they might develop a few command-line utilities or Component Object Model (COM) objects, allowing for some scriptable administrative capability. Rarely did the WMI or COM interfaces fully duplicate all the functionality available in the graphical console. This often meant that some administrative tasks could be accomplished via the command-line or a language like VBScript, but you couldn’t do everything that way. You’d always be back in the graphical console for something, at some point. Not that graphical interfaces are bad, mind you. After all, they’re how Microsoft has made billions from the Windows operating system. Yet clicking buttons and selecting check boxes can only go so fast, and with commonly performed tasks like creating new users, manual button-clicking is not only tedious, it’s prone to mistakes and inconsistencies. Administrators of *nix systems have spent the better part of a decade laughing at Windows’ pitiable administrative automation and third parties have done very well creating tools like AutoIt or KiXtart to help fill in the gaps for Windows’ automation capabilities. That’s no longer the case, though. PowerShell is now a part of the Microsoft Common Engineering Criteria and it occupies a similar position of importance with product groups outside the Windows operating system. Now, administrative functionality is built in PowerShell, first. Any other form of administration, including graphical consoles, utilizes the PowerShell based functionality. Essentially, graphical consoles are merely script wizards that run PowerShell commands in the background to accomplish whatever they’re doing. This is becoming more evident with the release of Windows 8 and Server 2012. Exchange Server 2007 was the first example of this—the graphical console simply runs PowerShell commands to do whatever corresponds to the buttons you click (the console even helpfully displays the commands it’s running, so you can use those as examples to learn from). Do I Need to Know All This? Yes. Look, clearly graphical user interfaces are easier to use than command-line utilities. PowerShell’s consistent naming and architecture make it easier to use. But in the end, it’s all about the command-line. A Windows admin who operates from the command-line can create a hundred new users in the time it takes to create just one in the graphical user interface. That’s an efficiency savings managers just can’t ignore. PowerShell lets you perform tasks, en masse, that can’t be done at all with the GUI, like updating the password a particular service uses to log in to dozens of computers. If you’ve been with Windows since the NT 4.0 days, you may remember a time when earning your Microsoft Certified Systems Engineer (MCSE) certification was not only a way to differentiate yourself from the rest of the admins out there, it was also a ticket to a $20,000 or more pay raise. Those days, of course, are gone. Today, management is looking at production applicable skills to differentiate the highly paid admins from the entry level ones. PowerShell is the skill management is after. Try finding an IT manager who’ll pay top dollar for a *nix admin who can’t script in Perl or Python or some

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.