Book Image

Getting Started with Powershell

Book Image

Getting Started with Powershell

Overview of this book

Table of Contents (19 chapters)
Getting Started with PowerShell
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Next Steps
Index

Preface

Since its introduction in 2007, Windows PowerShell has become the de facto scripting solution for Windows system administrators and other IT professionals. With its extensive functionality and powerful language, PowerShell can be used to automate almost any area of the Windows ecosystem. If you haven't learned PowerShell yet, there's no time like the present. This book will guide you through the most important topics to begin your learning journey. If you have used PowerShell before but wish to have a refresher, this book should serve as a guide to the topics that you need to understand in order to be successful in using PowerShell for your scripting and automation needs.

What this book covers

Chapter 1, First Steps, covers the installation of Powershell and the validation of the installed version, as well as how to issue the first few commands.

Chapter 2, Building Blocks, introduces the "Big 3" cmdlets that reveal the workings of the PowerShell cmdlets.

Chapter 3, Objects and PowerShell, explains how the output in PowerShell is always an object, and how we can deal with these objects.

Chapter 4, Life on the Assembly Line, presents the PowerShell pipeline and the *-object cmdlets that provide a tremendous ability for data manipulation.

Chapter 5, Formatting Output, explains the PowerShell formatting system, including how the output is formatted by default, as well as how to control formatting.

Chapter 6, Scripts, shows how sequences of commands can be packaged into a reusable unit.

Chapter 7, Functions, explains how to use functions as a second way of building reusable blocks of code.

Chapter 8, Modules, demonstrates PowerShell's method of organizing code libraries.

Chapter 9, File I/O, shows several ways to work with files in PowerShell for input and output.

Chapter 10, WMI and CIM, explains how to access WMI repositories with the WMI and CIM cmdlets.

Chapter 11, Web Server Administration, demonstrates a few techniques to use PowerShell to administer the IIS web server.

Appendix, Next Steps, suggests some "next steps" that you will find useful as skills to add to your PowerShell repertoire.

What you need for this book

Most of the examples in the book will work with PowerShell Version 2.0 and above. In the sections where a higher version of the engine is required, it will be indicated in the text. You should have no problems running the provided code on either a client installation (Windows 7 or greater) or a server installation (Windows Server 2008 R2 or higher).

Who this book is for

This book is intended for the Windows administrators or DevOps users who need to use PowerShell to automate tasks. Whether you know nothing about PowerShell or know just enough to be dangerous, this guide will give you what you need to take your scripting ability to the next level.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Here we can see that the Get-ChildItem cmdlet has three aliases."

A block of code is set as follows:

ForEach ($placeholder in $collection){
  #Code goes here
}

Any command-line input or output is written as follows:

%WINDIR%\System32\WindowsPowerShell\v1.0\

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "On the shortcut tab of the properties window, press the Advanced button."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.