Recently, I was looking for a scripted method for cold snapshotting of vRA in enterprise deployment. First, I wanted to confirm the shutdown order. VMware’s product documentation is quite limited regarding this topic, but it describes the right shutdown order. Looking further I found a better explanation here, where the documentation talks about vRA backup order. Of course, I wanted to check the proper starting procedure as well. I found it quickly here.
Well equipped with all information needed, I decided to write a script. Usually I use PowerCLI for tasks related to VMware software. I was sure that someone had the same idea before me so in order not to reinvent the wheel I started to check what Google will find.
I found a few elegant approaches, but one was the most interesting and inspiring. Distributed vRealize Automation 7.x Orchestrated Shutdown, Snapshot and Startup using PowerCLI Razz made it the way that I found I could use in my environment. I adjusted the script to my needs and it worked quite well. Of course, there is a lot to polish, but it works for me.
I decided to share Razz’s script adjusted by me. Maybe it will help someone with their administration tasks related to vRA.
VMware PowerCLI is a powerful tool for daily task for every Admin. The pure console is most commonly used. However, there are a few alternatives to the simple console which could make the use of PowerCLI even more handy. I’ll describe them shortly in the next a few lines.
Powershell ISE script editor, which provides a better user experience. It’s divided into two panes. The upper pane is for viewing/editing script files, and the lower pane is for running individual commands and displaying their output (an analog of the standard PowerShell console).You can execute PowerCLI commands in the lower pane of PowerShell ISE or in the PowerShell console. It will be usefull also during the first steps with PowerCLI through analysing of some ready downloaded from Internet scripts.The most convenient way to do is to open a script in the upper pane of Powershell ISE. In this way you can select each individual command and executee by pressing F8 or “Run Selection” button. When the command execution is finished you will see “Completed” message at the bottom of the console.
PowerGUI – it’s another script editor made by Quest Software which was acquired by Dell. IMHO it’s better organised than PowerShell ISE, the functions are rather simillar. However, instead of tabs with your scripts here you will be able to see the whole folder-tree with different kinds of scripts. It’s really helpful when you work with more than a few scripts.
To begin the jurney with PowerCLI we need to start from the installation of PowerCLI itself.
The installation can be done on a Windows based system, that could be some kind of an administration server. The installation files can be found on this VMware site.
There are a few versions available, they are released asynchronously with vSphere and the version numbers do not exactly correspond to vSphere versions. The most recent version is 6.5 whilst there are other like 6.3, 6.0 or 5.8 available.
Before you install the PowerCLI I recommend to change the Execution Policy of Powershell. It is required to run scripts. To do it, run Windows PowerShell as administrator and execute fallowing command:
The installation process is really straightforward, that’s why I will not spam the screanshoots of installations here.
After you finish the installation you can run it and see the first Welcome screen like this:
The first command I suggest to use is:
it lists all the available commands. However to display any information about virtual infrastructure you need to connect to a vCenter server or ESXi host. We will do it in the next part after introduction of useful tools which can be used in conjunction with PowerCLI.
I was always keen on getting deeper knowledge about PowerCLI or in other words – start to use it in daily administrative tasks. I decided to do something with it and I think it would be the best way to write my own guide in a form of structured notes and share it here with you. Perhaps someone would find it useful.
Therefore in PowerCLI & VMA tab you could find an agenda of this course which will be systematically updated with next parts.
There are planned fallowing parts:
VMware PowerCLI – Introduction
Basic commands to generate and export reports
Monitoring VMs with PowerCLI
Managing VMs using PowerCLI
Managing multiple VMs based on their tags
Monitoring ESXi hosts with PowerCLI
Managing ESXi hosts using PowerCLI
Managing virtual networks using PowerCLI
Managing Cluster-wide settings using PowerCLI
Complete ESXi configuration with a single script
If you have any sugestions what else should be included in such course, do not hesitate to contact me via comments.