New PowerCLI Book–Mastering PowerCLI by Sajal Debnath

There is a new PowerCLI Book on the market and recently I had a chance to talk to the writer, Sajal Debnath, we asked him a few questions about the new book, make sure you check out the below Q&A with Sajal where he explains more about PowerCLI, why you should use it, the book and more about him.

First and foremost, where can we find the book?

imageYou can get the book from publisher website:

From Amazon:

From Amazon India:

Who is Sajal?, tell us about yourself and how you started using PowerCLI?

Sajal Debnath

I am a Technocrat with more than 12 years of experience mainly in Operating Systems, Datacenter Virtualization and Cloud Computing.

I started working in VMware technologies from 2008 and prior to that I mainly worked in Tru64 Unix and various Linux flavors. Till 2009 my programming and scripting tasks were limited to writing small tools in C and extensive Shell Scripting in Linux and Unix environments. In the year 2009 I had a requirement for a daily health check report for vSphere environment from front line system admins of the company I worked for.

This started me thinking and while searching in internet I came across a script vCheck (Daily Report) and related blog from Alan Renouf. Since I specifically worked on *Nix environment so was unaware of PowerShell and PowerCLI environment. This script introduced me to the wondrous world of PowerShell and PowerCLI and I learned the subjects while customizing the script to suit our requirement.

For next 2 years I created many small scripts for different requirements. Back in 2011 I started working with VMware and worked very closely with a major Indian Govt. customer National Informatics Center. Among others specifically for this customer I had to solve many tough/tricky problems with PowerCLI.

Many a times PowerCLI was the only way I could provide a solution to a specific requirement from their side.

With other PowerCLI books on the market what do you think makes this one different?

While learning the topic I faced following two major problems:

1. Since PowerCLI is based on PowerShell so to master PowerCLI you need to master PowerShell in certain areas. Note, I did not want to master all the areas of PowerShell but only those areas which when mastered will help me master PowerCLI and write production grade scripts. But after looking in many places I could not find a single THE BOOK for that. I had to look in many different books for getting all the relevant information.

2. The majority of the books were written from a developer perspective. So I found the books to be too much developer-ish for my liking.

3. In all my years of experience as a working professional and before that as a student and teacher, I have seen primarily two methods of explanation:

The first approach, and the most widely used one, is to take an example problem and solve it while explaining the solution to the student. This way, the student learns how to solve a particular type of problem. The second approach is the one in which a teacher explains the basic logic and principles of the solution behind a problem, and then asks the students to solve the problem all by themselves.

As a student, I always found myself struggling with the first approach. Though the first approach was easier to understand, it tends to limit my knowledge only to solving similar problems. Because of the lack of the understanding of the underlying logic, when given a new problem, I could not solve it most of the time. This happened especially in mathematical problems. It was like showing me a program written in C to implement Dijkstra’s algorithm and explaining how this program was written. Knowing only this, will I be able to implement any other algorithm in C or utilize Dijkstra’s algorithm for my advantage? Probably not. Instead, if someone teaches me the different aspects of C language and how to write programs using C, then I can utilize this knowledge to write any programs.

You may disagree or agree with me, but I always preferred the second approach as it worked for me and gave me a better understanding and hold on the topic.

So, throughout this book, I tried to explain all the building blocks of advanced PowerShell and PowerCLI scripting and then provided examples to showcase what I am trying to say. I tried this approach with the hope that it will give you a better understanding and clarity of the underlying constructs so that you can build on top of this.

This book does not cover only PowerCLI but many topics of pure PowerShell as well, for example, Chapter 2 is all about Writing Advanced Functions, Chapter 11 is about creating Windows GUI etc.

Also this book is written from a System Admin perspective, so you need not be a development wiz to understand the topics. I have tried to keep the topics as simple as possible.

What do you cover in the book?

  • Chapter 1 is a refresher for PowerShell and PowerCLI, it refreshes the basics of PowerShell and introduces you to concepts that are necessary to develop, run, and test PowerShell scripts using PowerCLI cmdlets.
  • Chapter 2 is all about Reusable Advanced Functions and Scripts.
  • Chapter 3 talks aboutd Deploying vSphere Hosts and covers how to automatically deploy and configure ESXi hosts using different tools, such as Image Builder, Auto Deploy, and Host Profiles.
  • Chapter 4 discusses how to configure and manage vSphere networking through standard and distributed switches using PowerCLI.
  • Chapter 5 discusses how to create and manage storage in a vSphere environment, including SAN, NAS, iSCSI, and VSAN.
  • Chapter 6 covers how to manage logical constructs in a vCenter environment, including but not limited to HA and DRS clusters.
  • Chapter 7 covers how to configure the different aspects of virtual machines and guest operating systems using PowerCLI.
  • Chapter 8 covers security hardening and patching of vSphere environments along with management of other VMware solutions, such as SRM, vCloud Air and vRealize Operations Manager.
  • Chapter 9 focuses on how to use the vSphere API in PowerCLI and how we can manage advanced aspects of a vSphere environment using APIs.
  • Chapter 10 discusses Representational state transfer (REST) APIs and how PowerCLI can be used to manage the VMware vRealize Automation environment using REST APIs.
  • Chapter 11 discusses how to create a Windows graphical user interface (GUI) using PowerShell and other tools.
  • Chapter 12 describes PowerShell scripting best practices. This chapter also covers two sample scripts, one to get a security report and another to find the capacity of a vSphere environment.

Who should buy this book, beginners, experts or all?

This book is mainly aimed towards system admins managing a vSphere environment or someone with beginner level of knowledge in PowerShell and PowerCLI, who wants to master the topic. This book will be helpful for beginners who has working knowledge of PowerShell and PowerCLI. This book will help you master the topic and write production grade scripts.

What script are you the most proud of?

During the course of time I had to write various scripts in PowerCLI provided below couple of scripts which really helped me in sticky situations:

1. I had to write a script for a vCD cloud environment where I had to produce Auto-Scaling functionalities. I had to do it quick and hence written a PowerCLI script with vCenter Alarms, it delivered perfectly what was required and within 2 days could give the functionality to customer what they were looking for.

2. For a large Cloud environment customer wanted a custom capacity report which we could not get through any other way. It was extremely customized and they wanted it in specific format only. So I had to write a script similar to the capacity report given in the book, but was more elaborate which reports of entire vCD and vCenter environment. I plan to modify and add this script in my blog. Though we do not get vCD environment today, but it will work pretty well with vCloud Air environment. So if you have a mixed environment then this can be your script to go.

Why, in your opinion should people use PowerCLI?

For any system administrator scripting is the most powerful and essential tool in their arsenal. If you want to automate VMware environment, then apart from vRealize Orchestrator perhaps PowerCLI is the most useful and powerful tool you have.

I would go so far and say it is more flexible and easier to use than vRO. If you want something done at scale, then probably you would use vRO. But if you want to automate quickly, generate reports as per your requirement then PowerCLI is the answer. Just imagine creating a workflow in vRO which can replicate the task of security checker script that I have given as an example in Chapter 12 of the book and you would understand what I am trying to say.

Again imagine replicating Alan’s vCheck in vRO or in any other way. Pretty scary right? So if you are like me who wants to be in control of his scripts, do the tasks quick and precisely then PowerCLI is the tool to go. Besides I am amazed at the power that it provides. While using PowerCLI, imagination is the limit for you. You can write pretty amazing serious programs using this. Also the ease with which you can do that is the best part.



5 comments have been added so far

  1. Thanks for sharing . Amazing knowledge which you have shared in this article. This PowerCLI Book is really great to learn about PowerCLI from beginner level to expertise level.

Leave a Reply

Your email address will not be published. Required fields are marked *