Skip to content

Instantly share code, notes, and snippets.

View chelnak's full-sized avatar
👀
What's cooking?

Craig Gumbley chelnak

👀
What's cooking?
View GitHub Profile
@chelnak
chelnak / getHostCDPInfo_Task.js
Last active December 29, 2021 09:28
vRO task to get CDP information of a vsphere host and send email
//input: userEmail [String]
//input: vmHost [VC:Host]
var csv = ""
// Setup Mail Client
var message = new EmailMessage();
message.smtpHost = "smtp-host@org.co.uk";
message.fromName = "vCenter Orchestrator";
message.fromAddress = "noreply@org.co.uk";
@chelnak
chelnak / Get-AzureRMResourceTypeAPIVersion.ps1
Created March 10, 2017 10:24
Small profile function to easily retrieve a list of API versions for a given Resource Type
function Get-AzureRMResourceTypeAPIVersion {
<#
.SYNOPSIS
Retrieve a list of API versions for a given ResourceTypeName
.DESCRIPTION
Retrieve a list of API versions for a given ResourceTypeName
.PARAMETER ProviderNamespace
@chelnak
chelnak / Template.js
Last active June 22, 2021 06:06
A vRO Scriptable task that will parse a JSON Resource Element
//vRO Scriptable task to parse a resource element and
//edit values
//inputs:
//jsonTemplate : ResourceElement
//reservationName : String
//subtenantId : String
//outputs
//payload : String
@chelnak
chelnak / Get-LatestGithubRelease.ps1
Last active January 25, 2021 23:32
Download the latest zip ball release of a github project
# --- Set the uri for the latest release
$URI = "https://api.github.com/repos/chelnak/vRAAPIClient/releases/latest"
# --- Query the API to get the url of the zip
$Response = Invoke-RestMethod -Method Get -Uri $URI
$ZipUrl = $Response.zipball_url
# --- Download the file to the current location
$OutputPath = "$((Get-Location).Path)\$($Response.name.Replace(" ","_")).zip"
Invoke-RestMethod -Method Get -Uri $ZipUrl -OutFile $OutputPath
/*
Name: getLinkProperties
Input: vCACHost - vCAC:VCACHost
Input: vCACVirtualMachine - vCAC:VirtualMachine
Description: List the properties for a vCAC entity object link
*/
//Set the name of the link here:
var linkName = "VMDiskHardware";
@chelnak
chelnak / vco-cli.jar-help.md
Last active August 12, 2019 02:20
vco-cli.jar help

vCO Package import/export command line tool

Description:

Command line tool, that provides basic vCO package import and export operations. As source or target it can have either .package file, or directory.

Usage:

java <java-parameters> -jar PackageToolCli.jar <command> <command-parameters>
@chelnak
chelnak / CustomPowerShellProfilePrompt.ps1
Created June 24, 2019 21:10
Custom prompt for PowerShell that displays your current Az subscription in the tile bar
function Prompt {
$CurrentTitle = $Host.UI.RawUI.WindowTitle
$Host.UI.RawUI.WindowTitle = "Loading Az ..."
Set-Location -Path $ENV:USERPROFILE/code -ErrorAction stop
$IsElevated = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if ($IsElevated) {
Write-Host "$([char]9788) " -ForegroundColor Red -NoNewline
@chelnak
chelnak / escapeURIString.ps1
Created September 16, 2016 14:51
Escape URI String with PowerShell
$URI = "/catalog-service/api/consumer/resourceViews/?withExtendedData=$($WithExtendedData)&withOperations=$($WithOperations)&managedOnly=$($ManagedOnly)&`$orderby=name asc&limit=$($Limit)&page=$($page)&`$filter=resourceType/id eq 'Infrastructure.Machine' or resourceType/id eq 'Infrastructure.Virtual' or resourceType/id eq 'Infrastructure.Cloud' or resourceType/id eq 'Infrastructure.Physical'"
$EscapedURI = [uri]::EscapeUriString($URI)
$Response = Invoke-vRARestMethod -Method GET -URI $EscapedURI -Verbose:$VerbosePreference
@chelnak
chelnak / getUserPrincipalEmailAddress.js
Created October 4, 2016 10:49
Retrieve the Email Address of a user principal in vRA with vRO
/*
- Retrieve the email address of a user principal
- Input: vCACCAFEHost [vCACCAFE:vCACHost]
- Input: principalId [String]
- Output: emailAddress [String]
*/
var tenant = vCACCAFEHost.tenant;