Book Image

Mastering PowerCLI

By : Sajal Debnath
Book Image

Mastering PowerCLI

By: Sajal Debnath

Overview of this book

Have you ever wished that every morning you could automatically get a report with all the relevant information about your datacenter in exactly the same format you want? Or whether you could automate that boring, exhausting task? What if some crucial task needs to be performed on a regular basis without any error? PowerCLI scripts do all that and much more for VMware environments. It is built on top of the popular Windows PowerShell, with which you can automate server tasks and reduce manual input, allowing you to focus on more important tasks. This book will help you to achieve your goals by starting with a short refresher on PowerShell and PowerCLI and then covering the nuances of advanced functions and reusable scripts. Next you will learn how to build a vSphere-powered virtualized datacenter using PowerCLI while managing different aspects of the environment including automated installation, network, and storage. You will then manage different logical constructs of vSphere environment and different aspects of a virtual machine. Later, you will implement the best practices for a security implementation in vSphere Environment through PowerCLI before discovering how to manage other VMware environments such as SRM, vCloud Director and vCloud Air through PowerCLI. You will also learn to manage vSphere environments using advanced properties by accessing vSphere API and REST APIs through PowerCLI. Finally, you will build a Windows GUI application using PowerShell followed by a couple of sample scripts for reporting and managing vSphere environments with detailed explanations of the scripts. By the end of the book, you will have the required in-depth knowledge to master the art of PowerCLI scripting.
Table of Contents (21 chapters)
Mastering PowerCLI
Credits
Foreword
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
Index

Foreword

In the last nine years that I've been with VMware India, I have had the privilege of hearing from several CIOs and heads of infrastructure that VMware is an industry innovator and leader, creating amazing products that are disrupting and evolving businesses and the personal lives of many of us. I consider myself extremely lucky to be leading one of the best technical teams in the IT infrastructure space today.

When one of these technical brains in my team, Sajal Debnath, who comes from a small village in West Bengal, told me that he is writing a book on Mastering PowerCLI, the first question I asked him was "Why scripting?". I asked this question because scripting is a popular and great way to make up for a product's shortcomings or missing features, and it can be a real-time saver for administrators. But, to the best of my knowledge, every new release of VMware's products tends to have several features or enhancements that have been requested by our customers.

Sajal told me that the reason he has been successful in meeting the demanding needs of his customers is his expertise in scripting. PowerCLI is a very powerful command-line tool that allows you to automate all aspects of vSphere management, including network, storage, VM, guest OS, and more. There are unimaginable things that you can do in a VMware environment, and it is impossible for any product to include all of these features. I've heard from some of my customers too that tasks, such as automatically controlling the growth of snapshots, reporting on thin provisioned disks and their over allocation, and so on, are areas where scripting comes to their rescue.

The second question that I asked was, why the need to write a book on this topic when there was plenty of documentation available in VMware itself and the PowerCLI community? This is when I realized that most of the documentation available is predominantly written for software developers who are from a scripting background. Having known Sajal for the last four years, I know that he is very much customer-driven. Having interacted with several system administrators in his career, he wanted to write this book purely for VMware administrators who spend every single day managing a virtual environment.

This book starts off with an introduction to PowerShell and PowerCLI. If you are new to it, then it walks you through the process of how to configure and manage hosts, VMs, and networks and storage in detail. But the chapters that I liked the most were Chapter 8, Managing vSphere Security, SRM, vCloud Air, and vROps and Chapter 10, Using REST APIs. Chapter 8, Managing vSphere Security, SRM, vCloud Air, and vROps, goes beyond normal vSphere management and deals with one of the most ignored aspects today, security. I have seen very few customers in India who give importance to security hardening of their VMware environments. With the increasing threat perception these days, it is absolutely imperative for you to pay attention to how you can keep environments secure. Chapter 10, Using REST APIs, discusses how you can use REST APIs to manage other VMware products beyond vSphere that may not have native PowerCLI cmdlets. Toward the end, it also gives you some sample scripts that you can use straightaway in your environments.

I believe that VMware is a very exciting technology company that allows us to deeply influence and rapidly evolve technology and business for our customers, and I want to thank Sajal for writing this book.

If this isn't enough to spark interest in reading further, I don't know what is! I highly recommend that you read this book.

B. S. Nagarajan

Senior Director, Systems Engineering, VMware India