Make vRA testing easier with these PowerCLI scripts

A while ago I posted a bunch of PowerCLI scripts that made my life easier when building vSphere environments. Lately I have been doing a lot of testing on vRealize Automation 7 for a customer. Amongst other things this also included migration testing and therefore I needed to swap back to pre-migrated state a lot. After shutting down, snapshotting, starting back up, reverting, starting back up on 13 VM’s manually a few times I got sick of it. I put together a few very simple scripts that made my life a lot easier and efficient.

Shut down script

This is an obvious one, it is used to shutdown VM’s. Specifically the vRA VM’s and in the correct order. This is important because vRA can get real nasty on you if not shutdown in the correct order. Think of message bus or elasticsearch issues.

Create snapshots

The next script ensures that all VM’s that make up the vRA environment get a new snapshot with name and description. Using a description on what is included in a snapshot sounds like it is overrated (you can have some info in the name), but I found that when the number of snapshots grows it gets harder to track what is included in each step.

Note that this script uses a text (csv) file called vravms.txt. This holds all VM’s that need to get snapshotted. Note that the first line is the column vmname and the rest are the actual VM names, makes sense?

Startup vRA

Now let’s see how to start the complete vRA environment in the correct order with the correct amount of time in between the different VM’s. The time-outs are needed because some elements need more time to start and if you are too quick it might not work as expected. Of course the times can vary depending on the speed of your environment. But I found this works fine for most environments.

Reverting snapshots

Last but not least, reverting snapshots. If you need to go back and forth between two states this might com in handy. This script allows you to revert all VM’s back to the previously created snapshot. This uses the same input file as the snapshot creation so you always snapshot and revert the same VM’s to minimise inconsistency.

Conclusion

Alright, I know these are not as elaborate as the previous scripts but they have been very helpful. If you need to stop, snapshot, start, revert, start a few times a day these are a welcome addition to your tools. Another reason I posted this is because I see a lot of interest in the PowerCLI scripts from my previous post, this tells me people are looking for things like this so I just share if I think it is useful.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.