Front matter

foreword

Sitting down to write this foreword, my first thought was, “Wow, there’s a lot to unpack here.” My own time with PowerShell started in 2005, about a year before the shell was unleashed at TechEd Barcelona 2006. Learn Windows PowerShell in a Month of Lunches, the progenitor of this book, was far from my first PowerShell tome. Jeff Hicks and I wrote three editions of Windows PowerShell: TFM with SAPIEN Technologies first. After those, I actually made a decision, if you can imagine it, to not write any more PowerShell books! But I quickly came to realize that the existing selection of PowerShell books—well over a dozen by then—was missing a major audience need. The books of the time were teaching PowerShell as a programming language, aiming for the fairly large audience of VBScript coders that existed at the time. But PowerShell itself was aiming for a far larger and broader audience: nonprogrammers.

That’s when I took the narratives I’d been using in live PowerShell classes and started constructing a new book: one that wouldn’t head directly to control-of-flow statements by chapter 3, and one that would really focus on a best-fit sequence of teaching to make learning PowerShell as easy as possible. I wanted to make, and keep, a promise: give me an hour a day for a month, and I’ll make you functionally useful in PowerShell. 

Month of Lunches, as a book series, had a bit of a rough road. Book publishers operate on razor-thin margins, and launching a new series consumes a lot of resources. A different publisher originally decided to give the series a shot but backed out at the last minute. Manning—in what I hope has been a fantastic decision for them—stepped up and said, “Let’s do it.” We developed a new cover art concept that was a radical departure from the company’s norm, showing how willing they were to think creatively about this new series.

Learn Windows PowerShell in a Month of Lunches was a solid hit, becoming one of the best-selling PowerShell books in the world. It’s been translated into a number of different languages, and for many people it was their first exposure to PowerShell. I’ve heard from thousands of people how the book helped them break into the world of PowerShell. For many, it was their first PowerShell learning experience. For most, it wasn’t their last, but I’m proud that so many people trusted Jeff and me to get them started.

When Microsoft finally made PowerShell open source (!!!!) and cross-platform (!!!!!!!), we knew it would be time for a new Month of Lunches book—one that addressed PowerShell instead of just Windows PowerShell.

But by that point, Jeff and I were a little burned out on writing. My own career was moving in a different direction—I’d accepted a VP role at my company, and I knew I’d be hard pressed to keep up with PowerShell’s rapidly changing and expanding world. My final book, Shell of an Idea: The Untold History of PowerShell, was in many ways a love letter to the community and product team that had been supporters and friends for more than a decade. It told the stories of how PowerShell only barely managed to come to life, and I knew as I wrote it that I wouldn’t have the time to write any more about PowerShell’s future.

That’s why I’m so glad that the authors of this volume stepped in. The PowerShell community in general is full of incredibly generous people, always willing to answer a question and help you out. “Stepping away,” for me, also meant stepping away from PowerShell.org, the website I cofounded, and the nonprofit that backed it. It meant stepping away from PowerShell + DevOps Global Summit, a conference I first financed on my American Express card. But the PowerShell community stepped up as they almost always do: new people agreed to keep the organization not only going, but also growing. James Petty, one of this book’s coauthors, is one of those folks, and I’m forever grateful to him and his team for keeping the community spirit alive.

This book largely builds on the narrative that I created for the first Month of Lunches title and that Jeff Hicks and I refined through three editions—along with Learn PowerShell Scripting in a Month of Lunches, a book that’s as relevant today as it was when we first wrote it. But this book breaks out of the Windows operating system and treats PowerShell as a true global citizen: you’ll find examples applicable whether you’re running PowerShell on Windows, Linux, or macOS—a huge undertaking for these authors, given the stark differences between those operating systems.

I remain incredibly grateful to the PowerShell community. They’ve made me feel welcomed, appreciated, and valuable—something I hope everyone can experience at some point. It’s a community I encourage you to explore, via PowerShell.org or the many other volunteer-driven websites, GitHub repos, Twitter accounts, and other outlets. You’ll be glad you did.

Finally, I want you to know that your investment of time in PowerShell will create impressive returns. PowerShell is almost unique among software in that it didn’t seek to reinvent anything. Instead, it simply wanted to take all the chaotic, crazy, powerful stuff that was already in the world and make it more consistent and easier to use. PowerShell respects Linux, for example, by not trying to impose a Microsoft worldview on that operating system. Instead, PowerShell simply makes everything Linux already is just a little easier to operate.

I hope your PowerShell journey, whether it’s just beginning or you’re well into it, will prove as fruitful and satisfying as mine has been. I hope you’ll show the authors of this book your support, because they’ve labored mightily to bring this into your hands. And I hope you’ll take your newfound knowledge and find ways to share it with others who are just beginning their journey. Regardless of what’s already been said or written about PowerShell, your take on it will prove to be the one that helps someone have the “aha!” moment that launches their own PowerShell success.

Don Jones

preface

Never in a million years would I have thought that one day I would be asked to help write any tech book, much less the fourth edition of Learn PowerShell in a Month of Lunches—the very book that started me on my journey many years ago.

When I heard that Travis Plunk and Tyler Leonhardt had signed on with Manning to write the fourth edition of the successful book, I thought, Who better to write the next edition than two of the people on the PowerShell team? To preserve the winning style of Don Jones and Jeffery Hicks from the earlier versions, Tyler and Travis would work from their original chapters. Because PowerShell was now available on Linux and macOS, however, this book would focus on those two operating systems and showcase the open source/cross-platform abilities of PowerShell 7. And the book would be called Learn PowerShell in a Month of Lunches rather than Learn Windows PowerShell in a Month of Lunches, which was the title of the first, second, and third editions of the classic book. Excited to see the expanded and updated version, I purchased the MEAP and was reading the chapters as they were released.

Fast-forward a year. PowerShell 7 was released. Also, readers and early reviewers of the book made it clear that Windows is still the OS where most admins spend their time, so they wanted the fourth edition to include Windows as well as Linux and macOS. So I was brought on board to finish up the book and update it to cover the latest version of PowerShell and the Windows OS. I took what Tyler and Travis had started and kept the project going, making sure that all three operating systems were represented. The book did end up being a little Windows heavy, but that’s to be expected, as, again, PowerShell still has more functionality on Windows. I came from the corporate environment, using PowerShell daily to support Windows servers.

It has been an amazing journey for me to come full circle, from reading the first book to helping write this edition. Whether you are just getting started with PowerShell or are a seasoned admin looking for the latest tips and tricks, I hope you enjoy this book.

James Petty

acknowledgments

I offer a huge thank-you to my wife, Kacie, for supporting me during this project. I also thank Don Gannon-Jones for his support, mentorship, and encouragement to join this project. This has been an amazing journey for me to come full circle from reading Don’s first Month of Lunches book on PowerShell to helping write this edition.

I would also like to thank the staff at Manning: Deirdre Hiam, my project editor; Carrie Andrews, my copyeditor; Katie Tennant, my proofreader; and Shawn Bolan, my technical proofer.

To all the reviewers: Aldo Solis Zenteno, Birnou Sebarte, Brad Hysmith, Bruce Bergman, Foster Haines, Giuliano Latini, James Matlock, Jan Vinterberg, Jane Noesgaard Larsen, Jean-Sebastien Gervais, Kamesh Ganesan, Marcel van den Brink, Max Almonte, Michel Klomp, Oliver Korten, Paul Love, Peter Brown, Ranjit Sahai, Ray Booysen, Richard Michaels, Roman Levchenko, Shawn Bolan, Simon Seyag, Stefan Turalski, Stephen Goodman, Thein Than Htun, and Vincent Delcoigne, thank you. Your suggestions helped to make this a better book.

about this book

We are glad you have decided to join us in a month-long journey! A month seems like a long time, but it will be worth it, we promise.

Who should read this book

This book is for a wide range of audiences; however, the primary audience is those who are just getting started with PowerShell. Job functions may include help desk or server administrators.

Most of the preliminary information you will need is covered in chapter 1, but here are a few things we should mention up front. First, we strongly suggest that you follow along with the examples in the book. For the optimal experience, we suggest you run everything on a virtual machine. We have done our best to make sure the examples are cross-platform, but as you will see, there are a few chapters that are Windows specific.

Second, be prepared to read this book from start to finish, covering each chapter in order. Again, this is something we’ll explain in more detail in chapter 1, but the idea is that each chapter introduces a few new things that you will need in subsequent chapters. You really shouldn’t try to push through the whole book—stick with the one-chapter-per-day approach. The human brain can only absorb so much information at once, and by taking on PowerShell in small chunks, you’ll actually learn it a lot faster and more thoroughly.

About the code

This book contains a lot of code snippets. Most of them are short, so you should be able to type them easily. In fact, we recommend that you do type them, because doing so will help reinforce an essential PowerShell skill: accurate typing! Longer code snippets are given in listings and are available for download from the book’s web page on the publisher’s website at www.manning.com/books/learn-powershell-in-a-month-of-lunches.

That said, you should be aware of a few conventions. Code always appears in a special font, just as in this example:

Get-CimInstance –class Win32_OperatingSystem 
 –computerName SRV-01

That example also illustrates the line-continuation character used in this book. It indicates that those two lines should be typed as a single line in PowerShell. In other words, don’t press Enter or Return after Win32_OperatingSystem—keep right on typing. PowerShell allows for long lines, but the pages of this book can hold only so much.

Sometimes code is also in bold to highlight code that has changed from previous steps in the chapter, such as when a new feature adds to an existing line of code. And sometimes you’ll also see that code font within the text itself, such as when we write Get-Command. That just lets you know that you’re looking at a command, parameter, or other element that you would type within the shell.

Fourth, you’ll see an element that we’ll bring up again in several chapters: the backtick character (`). Here’s an example:

Invoke-Command –scriptblock { Get-ChildItem } `
   -computerName SRV-01,localhost,DC02

The character at the end of the first line isn’t a stray bit of ink—it’s a real character that you would type. On a US keyboard, the backtick (or grave accent) is usually near the upper left, under the Esc key, on the same key as the tilde character (~). When you see the backtick in a code listing, type it exactly as is. Furthermore, when it appears at the end of a line—as in the preceding example—make sure that it’s the last character on that line. If you allow any spaces or tabs to appear after it, the backtick won’t work correctly, and neither will the code example.

You can get executable snippets of code from the liveBook (online) version of this book at https://livebook.manning.com/book/learn-powershell-in-a-month-of-lunches. The complete code for the examples in the book is available for download from the Manning website at www.manning.com/books/learn-powershell-in-a-month-of-lunches, and from GitHub at https://github.com/psjamesp/Learn-PowerShell-in-a-Month-of-Lunches-4th-Edition.

liveBook discussion forum

Purchase of Learn PowerShell in a Month of Lunches, Fourth Edition, includes free access to liveBook, Manning’s online reading platform. Using liveBook’s exclusive discussion features, you can attach comments to the book globally or to specific sections or paragraphs. It’s a snap to make notes for yourself, ask and answer technical questions, and receive help from the authors and other users. To access the forum, go to https://livebook.manning.com/book/learn-powershell-in-a-month-of-lunches/discussion. You can also learn more about Manning’s forums and the rules of conduct at https://livebook.manning.com/discussion.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between readers and between readers and authors can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the forum remains voluntary (and unpaid). We encourage you to ask them some challenging questions lest their interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

about the authors

James Petty is the president and CEO of the DevOps Collective, which runs PowerShell.org, and is also a Microsoft Cloud and Datacenter MVP. He organizes the PowerShell + DevOps Global Summit held each April and the DevOps + Automation Summit held in the fall, and he has helped facilitate multiple PowerShell Saturdays around the United States. A contributing author to The PowerShell Conference Book, volume 1, he is also cofounder of the Chattanooga PowerShell user group and the cochair for PowerShell on the River, a two-day PowerShell conference hosted in Chattanooga, Tennessee.

Travis Plunk has been a software engineer on various PowerShell teams since 2013 and at Microsoft since 1999. He was involved in open sourcing PowerShell and moved the core PowerShell engine over shortly after PowerShell was made open source.

Tyler Leonhard has been a software engineer on the PowerShell team for about 2 years and at Microsoft for almost 3. He is a core maintainer of the PowerShell extension for VS Code and is also active on social media (Twitter, Twitch streams, LinkedIn) as a member of the PowerShell team.

Jeffery Hicks is an IT veteran with 30+ years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies, emphasizing automation and efficiency. He is a multiyear recipient of the Microsoft MVP Award. He works today as an independent author, teacher, and consultant. Jeff has taught about PowerShell and the benefits of automation to IT Pros worldwide. He has authored and coauthored several books, writes for numerous online sites and print publications, is a Pluralsight author, and is a frequent speaker at technology conferences and user groups. You can keep up with Jeff on Twitter (http://twitter.com/JeffHicks). You'll find his online work at https://jdhitsolutions.com/blog and https://jeffhicks.substack.com.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.9.7