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

Using SAPIEN PowerShell Studio


In the previous section, we discussed how we can utilize WinForms to give a frontend to our scripts. But doing it manually is really painful. To build a simple tool such as the one we have built, we had to write 421 lines of code. We can simplify all these with the use of PowerShell Studio 2015 by SAPIEN. SAPIEN earlier had a free community edition Primal Forms, which has since been discontinued. PowerShell Studio 2015 is a paid version, but if you create a lot of GUIs using WinForms in PowerShell, then this is an invaluable tool for you. It comes with a 45-day trial period so that you can try it before making the final decision. Without wasting much time, let's start the discussion about building a GUI using this tool.

We will start by creating a New Form Project:

We give it the name TextBox_PStudio:

This gives us a blank form:

On the left-hand side, we can see that there is a Toolbox option. There are all kinds of control and control sets available in Toolbox...