Chapter 1. PowerShell and PowerCLI Refresher
Well, you have taken up this book that means you already know about PowerShell and PowerCLI and in all probability use it in your day to day routine and now you want to learn more in-depths about them. You want to master the art of writing production-grade scripts for your environment or for others, and in the process, master the mysteries of this technology.
In all my years of experience, I have seen that the difference between a normal technical person and the coveted one is the advanced knowledge. To become a master of your technology, you need to know the background of the technology, how it works, how it behaves, and so on. Any person working with a tool knows how to run the tool, knowing the logic behind the tool, knowing how the tool exactly works at the back-end makes you different, it makes you the master of the tool. So, if you want to master PowerCLI, then you need to expand your horizons beyond the normal cmdlets, and you need to go deeper and get to know the intricacies of PowerShell because it is based on it.
My work experience varies widely, but it has all been related to the data center environment. In all my years of work, my programming has been related to writing scripts for automating daily tasks in the data center environment or writing small tools for the DC environment. At the time of learning advanced topics of PowerShell and PowerCLI, most of the books that I read were written more from a developer's perspective, making them 'developer-ish' in nature (sounds familiar?). I also had to look into many different books to find different topics; there was not a single place where I could get all the topics (which covers both PowerShell and PowerCLI), which covered the advanced topics.
This book tries to cover all or most of the advanced topics of PowerShell and PowerCLI to enable you to master the subject and become a master scripter/tool maker, but at the same time, this book is written from the perspective of a system admin. To achieve this, I would try to avoid the developer jargons and replace them with normal, simple examples. Note that this is a 'mastering PowerCLI' book, not a mastering PowerShell book, so the examples given in this book are from the PowerCLI perspective. You can say that I am looking at PowerShell through the eyes of PowerCLI, and we will cover those topics of PowerShell that will enable us to write production-grade scripts for managing VMware environments.
In this chapter, we will cover the following topics:
- The essence of PowerShell and PowerCLI
- Programming constructs and ways in which they are implemented in PowerShell
- Automation through PowerShell scripts
- How to run scripts from Command Prompt and as scheduled tasks
- Using GitHub
- Testing your scripts using Pester
- How to connect to a vCenter environment and other VMware environments using PowerCLI cmdlets