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 / BackConnectionHostNames.ps1
Last active August 29, 2015 14:17
Configure BackConnectionHostNames
#Add BackConnectionHostNames
#You can use 'r for carriage return as this is a MultiLine String key
$hosts ="iaas-web.corp.local`r`niaas-mgr.corp.local`r`niaas-web-01.corp.local`r`niaas-web-02.corp.local"
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\LSA\MSV1_0 -Type MultiString -Name BackConnectionHostNames -Value $hosts
@chelnak
chelnak / SearchInFiles.ps1
Created March 27, 2015 13:12
Search for a string in multiple files
#Needed to search for invalid hostname inside lots of config files
$wrongHost = "the-host.com"
$path = "D:\Program Files (x86)\VMware\vCAC\"
Get-ChildItem -Path $path -Filter *.config -Recurse | ? { !$_.PSIsContainer } | % {
$f = Get-Content $_.FullName
$c = $f | % { $_ -match $wrongHost }
@chelnak
chelnak / RequestTemplateSAN
Last active August 29, 2015 14:20
CertReq - SAN Template
[Version]
Signature="$Windows NT$"
[NewRequest]
Subject = "CN=servername.corp.com, OU=, O=, L=, S=, C="
Exportable = TRUE
KeyLength = 2048
KeySpec = 1
@chelnak
chelnak / getCatalogResourceForUser.js
Last active August 29, 2015 14:20
vRA: Get Catalog Resources for a User
//Inputs:
//host: vCACCAFE:vCACHost
//user: string
//Can get host like this if needed:
//var host = vCACCAFEEntitiesFinder.getHost("id-of-host-yes");
var catalogClient = host.createCatalogClient();
var catalogConsumerResourceService = catalogClient.getCatalogConsumerResourceService();
var filter = new Array();
@chelnak
chelnak / Invoke-RestMethod.ps1
Created May 11, 2015 15:49
Invoke-RestMethod
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", "application/json")
$headers.Add("Content-Type", "application/json")
$url = "whatever.com"
$r = Invoke-RestMethod $url -Headers $headers
@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 / getClusterCDPInfo_Task.js
Last active March 31, 2016 06:51
vRO task to get CDP information from a vsphere cluster and send email
//input: userEmail [String]
//input: cluster [VC:ClusterComputeResource
var csv = ""
var hosts = cluster.host
// Setup Mail Client
var message = new EmailMessage();
message.smtpHost = "smtp@org.co.uk";
message.fromName = "vCenter Orchestrator";
#!/usr/bin/python
import getpass
import json
import os
from argparse import ArgumentParser
from jinja2 import Environment, FileSystemLoader
from vraapiclient import reservation
#!/usr/bin/python
import json
#full path to cloudclient
cloudClientPath = '/PATH_TO_CLOUD_CLIENT/bin/cloudclient.sh'
#Path to your prefix json file. If just the filename, it will look in the script directory
prefixJSONFile = 'vra-machineprefixes.json'
#Path to the resulting script file. If just the filename, it will look in the script directory
prefixScriptFile = 'machineprefix-cloudclient-commands.sh'
@chelnak
chelnak / createCloudClientScript-machineprefixes.ps1
Last active August 29, 2015 14:26
Migrate vRealize Machine Prefixes with PowerShell
#full path to cloudclient
$cloudClientPath = "D:\cloudclient\bin\cloudclient.bat"
#Path to your prefix json file
$prefixJsonFile = "vra-machineprefixes.json"
#Path to the resulting script file
$prefixScriptFile = "machineprefix-cloudclient-commands.ps1"
$machinePrefixes = Get-Content -Raw -Path "$($prefixJsonFile)" | ConvertFrom-Json
$outFile = @()