Wednesday, August 19, 2015

Using FreeMarker to assign Agility VM properties to a PowerShell variable.

It's been about a month since I last posted. Well, I've been a little busy. I've been starting the interview process for a few companies. Since this upcoming Fall semester is my last, it is imperative that I have a software engineering job lined up for January 2016. And my week is spent full-time as a tech engineer working in the automation department at some company where I create PowerShell scripts leveraging FreeMarker that are utilized within CSC's Agility platform.


So...... to the point of this blog. I've been working on a script lately that validates the properties of an instance and then compares it to the properties listed in Agility using a Java API called FreeMarker. I just want to display an example for extracting properties from VMs in Agility and then assigning it to a variable in PowerShell.

*NOTE* Scripts leveraging FreeMarker can only be run in Agility with the extensions button enabled when adding/creating the script in Agility. They will not execute properly in PowerShell ISE, etc.. The FreeMarker aspect of the script will only be viewed as a multi-lined comment in traditional PowerShell editor settings.


Here's an example code snippet that extracts a designated VM asset property from an Agility template in agility and assigns it to a PowerShell variable...


<#assign agilityOSProperty = vmAssetProperty(this, "template.domain")>
$agilityOSProperty = '${agilityOSProperty.stringValue}'
$agilityOSProperty = $agilityOSProperty.ToUpper()



link that may be of interest ---> http://freemarker.org/


No comments:

Post a Comment

Getting 60gb of Json Data into MySql

The other day I had write a 60gb Json file to a MySql database. The data was already clean and deduped, so all that had to be done was to wr...