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
#!/usr/bin/python
import getpass
import json
import os
from argparse import ArgumentParser
from jinja2 import Environment, FileSystemLoader
from vraapiclient import reservation
@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";
@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 / 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 / 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 / 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 / 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 / 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 / Delete-IISLogs.ps1
Last active August 29, 2015 14:16
Delete IIS logs
function Clean-Logs {
<#
.SYNOPSIS
Remove files oder than x days from x location
.DESCRIPTION
Mainly used to remove IIS logs that are older than a certain number of days.
.EXAMPLE
Clean-Logs -Retention 7 -Directory D:\Logs
.PARAMETER Retention
Number of days to retain logs. Specifying 7 will remove logs older than 7 days.
@chelnak
chelnak / Remove-Hotfix.ps1
Last active August 29, 2015 14:16
Windows Hotfix Removal
#Run - Get-Cluster CLUSTERNAME | Get-VM | Select Name | Sort Name | Export-Csv ./CLUSTERNAME.csv -NoTypeInformation
$clusterVMs = Import-Csv '.\ASMCL06.csv'
$KB = "KB2982791"
$KBNumber = $KB.Replace("KB", "")
$RemovalCommand = "wusa.exe /uninstall /kb:$KBNumber /quiet /norestart"
$Domain = "corp.local"
$report = @()
$clusterVMs | % {