Book Image

PowerCLI Essentials

By : Chris Halverson
Book Image

PowerCLI Essentials

By: Chris Halverson

Overview of this book

Have you ever wished you could automatically get a report with all the relevant information about your VMware environments in exactly the format you want? Or that you could automate a crucial task that needs to be performed on a regular basis? Powerful Command Line Interface (PowerCLI) scripts do all these things and much more for VMware environments. PowerCLI is a command-line interface tool used to automate VMware vSphere environments. It is used to handle complicated administration tasks through use of various cmdlets and scripts, which are designed to handle certain aspects of VSphere servers and to help you manage them. This book will show you the intricacies of PowerCLI through real-life examples so that you can discover the art of PowerCLI scripting. At the start, you will be taught to download and install PowerCLI and will learn about the different versions of it. Moving further, you will be introduced to the GUI of PowerCLI and will find out how to develop single line scripts to duplicate running tasks, produce simple reports, and simplify administration. Next, you will learn about the methods available to get information remotely. Towards the end, you will be taught to set up orchestrator and build workflows in PowerShell with update manager and SRM scripts.
Table of Contents (13 chapters)
PowerCLI Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

VMware PowerCLI is one of the most utilized command-line interfaces for a VMware vSphere System Administrator. Covering more than 480 different functions of a vSphere system, PowerCLI and PowerShell have become one of the staples of an automation enabler in this space. Taking the viewpoint of an administrator with some experience, Essential VMware Administration with PowerCLI introduces the idea and concept of taking the beginning steps toward developing one-line commands into multi-line scripts that can be used not only by the reader but also by others within their organization.

This book is designed with the mindset of think first, design second, script next, and test last. It covers getting the tool and integrating it with other products in the VMware stack and attempts to build on the knowledge outlined from the chapter before.

What this book covers

Chapter 1, An Introduction to Essential Administration with PowerCLI, sets the stage through discussing how to get PowerCLI, what the difference is between PowerShell and PowerCLI, discusses its version history, and provides a starting point with its installation. This chapter is a means to get you up and running with the right version and the best tools for the job.

Chapter 2, Comparing Point and Click Administration to PowerCLI and Scripting, looks through the eye of an administrator, helping to redefine the typical point and click doldrums and compare them to the exciting and provocative world of scripting.

Chapter 3, Enhancing the Scripting Experience, takes the previous chapter and builds upon it. This chapter will enhance the experience through better practices, help a team build a repository, and make the code reusable.

Chapter 4, Windows Administration within VMware Administration, starts with the preparation of a DevOps practice and the roles around it. This programmatically helps bridge the gap for becoming operationally transformed and influences how an organization can build a private cloud type of environment. We will use this mindset to build and provision a Windows script host, and run PowerCLI and Windows-based PowerShell in the same script.

Chapter 5, Workflows and vRealize Orchestrator, introduces the vRealize Orchestrator product, how workflows are developed, and where to use them. The chapter will provide a walkthrough of the installation of vRealize Orchestrator and where it fits in the environment.

Chapter 6, Running Workflows with Other VMware Products, discusses other VMware products such as NSX, Orchestrator, vRealize Operations Manager, Site Recovery Manager, and VSAN. It takes each technology and product, explains the product, where it fits, and then, finally, how PowerCLI can integrate with them.

What you need for this book

This book depends upon you, the reader, to have a vSphere environment to connect to and run the scripts against. This can be achieved through a try and buy download from VMware.com or with a company Test environment. A vSphere environment typically includes:

  • A VMware vCenter server utilizing a Windows-based standalone installation or a vCenter Server Appliance

  • An attached VMware ESXi server

This book was written using PowerShell v3 on Windows Server 2008 R2 VM or on PowerShell v4 running on Windows Server 2012 R2 VM. The scripts were tested on multiple systems for compatibility and to reduce errata in the scripts. PowerCLI version 6.0 R1 and R2 were used.

Who this book is for

PowerCLI Essentials is focused toward virtualization professionals and system administrators who want to discover and learn about the automation techniques associated with PowerCLI for complex virtual environments.

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: "The Get-PowerCLIConfiguration command will show three scopes of the configuration, Session, User, and AllUsers."

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

$PSVersionTable.PSVersion.Major

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: "Set Screen Buffer Size for Width and Height whenever possible."

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.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

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.