Skip to content

Instantly share code, notes, and snippets.

var cred = Server.getCredential();
vmPassword = VcPlugin.createCustomizationPasswordFromCredentials(cred, true).value;
vmUsername = cred.username;
@burkeazbill
burkeazbill / install.bat
Last active October 12, 2017 14:35
install.bat for Add DNS Record Blueprint for vRA
@echo off
setlocal
set logfolder="%cd%\logs"
set logfile="%logfolder%\install.log"
if not exist %logfolder% mkdir %logfolder%
set root=%cd%
FOR %%F IN (%root%\*vro*.zip) DO (
set zipfile=%%F
@burkeazbill
burkeazbill / prepare_vra_template.sh
Last active April 24, 2018 17:46
Updated prepare_vra_template.sh to support PhotonOS
#!/bin/bash
# Copyright (c) 2015-2016 VMware, Inc. All rights reserved.
#
# Description: VMware vRealize Automation and Software Services agents installation script
# Modified on April 20th, 2017 by Burke Azbill to support execution on PhotonOS 1.0 GA
# Global Constants
[ -z $GUGENT_INSTALL_PATH ] && GUGENT_INSTALL_PATH=/usr/share/gugent
JRE_RELEASE=1.8.0_112
DEFAULT_JAVA=false
@burkeazbill
burkeazbill / sortDatastores.js
Created March 9, 2017 14:44
sortDatastores.js
/*
Authors: Burke Azbill & Bill Call (2011)
Name: sortDatastores.action
Description: This script is intended to be used as a vRealize Orchestrator Action. It will return an array of sorted VC:Datastore objects,
sorted as defined by the sortType input (freeSpace, freeSpaceDesc, capacity, capacityDesc, uncommitted, uncommittedDesc, nameDesc)
where "Desc" means Descending. If no Sort Type is defined, then the default sort is by Name.
This code also serves as an example on how to sort arrays of Objects in vRealize Orchestrator
Inputs: datastores (Array/VC:Datastore), sortType (string), logResults (boolean)
@burkeazbill
burkeazbill / getADUserByName.js
Last active August 17, 2016 07:16
VMware Orchestrator javascript to retrieve an Active Directory User object (AD:User) based on a string for the username
// Here's a quick one-liner to get a user by name.
// Inputs: username (string), adHost (AD:AdHost) - "adHost" host param optional. If not specified, only the default AD host is searched.
// Output: user (AD:User)
// Option 1: quick 1-liner
user = ActiveDirectory.searchExactMatch("User", username, 1, adHost)[0];
// Option 2: If you want a bit more error handling, try this:
/*
var users = ActiveDirectory.searchExactMatch("User" , UserID, 1, adHost);
for each (usr in users){
@burkeazbill
burkeazbill / stripQuotes.js
Created April 7, 2016 13:09
vRealize Orchestrator javascript to strip quotes from a string
function stripQuotes(quoteString){
return quoteString.replace(/\”/g,””);
}
@burkeazbill
burkeazbill / stripBrackets.js
Created April 7, 2016 13:05
vRealize Orchestrator Javascript function to strip brackets from a string
function stripBrackets(string) {
return string.replace(/\[/g, "").replace(/\]/g, "").replace(/\"/g, "");
}
@burkeazbill
burkeazbill / displayPropertyKeys
Created October 28, 2015 14:00
This is a simple Orchestrator Javascript snippet that demonstrates how to work with a Properties object
/*
Working with Orchestrator Properties objects is actually pretty easy. See the API Explorer for full details.
The object has a keys property that is an array of strings containing the name of each available property.
*/
// Manually defining a simple set of properties here. The first value in the put() is a String containing the name of the property
// the second value is the actual value - this can be any object type Orchestrator understands
// Initialize a new Properties object
var payload = new Properties();
// Populate the properties object with a few key/value pairs
@burkeazbill
burkeazbill / getVcloudGatewayInfo.js
Created September 10, 2015 16:59
getVcloudGatewayInfo.js
/*
Author: Burke Azbill
Purpose: Display various properties of a vCloud:Gateway object in vRealize Orchestrator (vRO)
Usage:
1) Create a new workflow with a single scriptable task in it
2) Add an input named "gateway" of type "vCloud:Gateway" and be sure the input is bound to the scriptable task
3) Paste this code into the scriptable task
4) Save and Close
5) Run the workflow, providing a valid vCloud:Gateway object as input
6) Review the Logs tab of your vRealize Orchestrator client
@burkeazbill
burkeazbill / getPasswordDate.js
Created January 30, 2015 21:32
AD User Password Date - vCO Script
/*
This script is for use with VMware vRealize Orchestrator
Assumes the Active Directory plug-in is installed/configured
Input: user (AD:User)
Output: passwordDate (Date)
*/
function getPasswordDate(user){
var lastPasswordSet = user.getAttribute("pwdLastSet");
var unixTime = (lastPasswordSet - 116444736000000000) / 100000;
var passwordDate = new Date(Math.round(unixTime));