Skip to content

Instantly share code, notes, and snippets.

@vmwarecode
vmwarecode / snippet.ps1
Last active August 11, 2016 15:27
Windows - Prepare vRA Template for vRA
#==============================================
# Generated On: 08/03/2016
# Generated By: Gary Coburn
# Automation Specialist
# Organization: VMware
# Twitter: @coburnGary
# Install bootstrap, java, and gugent
#==============================================
#----------------------------------------------
#==================USAGE=======================
@vmwarecode
vmwarecode / guestinfo.py
Created March 3, 2016 23:59
GuestInfo command for ESXi
#!/usr/bin/python
#
# *******************************************************
# Copyright VMware, Inc. 2014. All Rights Reserved.
# *******************************************************
#
# DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
# WARRANTIES OR CONDITIONS # OF ANY KIND, WHETHER ORAL OR WRITTEN,
# EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY # DISCLAIMS ANY IMPLIED
# WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY # QUALITY,
@vmwarecode
vmwarecode / snippet.ps1
Created March 16, 2016 21:04
PowerCLI Script to Install VMware Host Patches
########################################
#
# PowerCLI Script to Patch Hosts
# Created by BLiebowitz on 3/4/2016
#
########################################
# Load PowerCLI Modules
if ( !(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) ) {
. “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1”
@vmwarecode
vmwarecode / snippet.ps1
Last active August 11, 2016 15:31
prepare_vra_template.ps1 7.0.1
#==============================================
# Generated On: 08/03/2016
# Generated By: Gary Coburn
# Automation Specialist
# Organization: VMware
# Twitter: @coburnGary
# Install bootstrap, java, and gugent
#==============================================
#----------------------------------------------
#==================USAGE=======================
@vmwarecode
vmwarecode / snippet.py
Created April 6, 2016 19:07
Virtual SAN 6.2 Capacity - Total and Free
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright 2016 VMware, Inc. All rights reserved.
2016-04-06 - Jase McCarty
To provide an exmple of VC side VSAN API access, it shows how to get VSAN cluster capacity
status by invoking the QuerySpaceUsage API of the
VsanSpaceUsage MO.
@vmwarecode
vmwarecode / snippet.sh
Created April 8, 2016 06:37
VSAN DIsk Decommission Script
/bin/sh
echo "Leaving the VSAN Cluster..."
esxcli vsan cluster leave
echo "Done"
echo "Disabling Auto Mode..."
esxcli vsan storage automode set --enabled false
echo "Done"
@vmwarecode
vmwarecode / snippet.sh
Created April 29, 2016 10:44
VDP Data Change Rate Output for all VMs
mccli client show --recursive | awk 'NR>4' | awk 'NR<2' | awk '{print $2}' | while read i; do avmgr getl --path="$i";done | awk 'NR>1' | awk '{print $2}'| while read i; do capacity.sh --client="$i" --days=5; done | tee -a ClientRateReport.txt
@vmwarecode
vmwarecode / snippet.ps1
Created May 5, 2016 06:58
PowerShell error resolution
function Resolve-Error ($ErrorRecord=$Error[0])
{
$ErrorRecord | Format-List * -Force
$ErrorRecord.InvocationInfo |Format-List *
$Exception = $ErrorRecord.Exception
for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException))
{ “$i” * 80
$Exception |Format-List * -Force
}
}
@vmwarecode
vmwarecode / snippet.js
Created May 11, 2016 22:28
Delete all NICs from vSphere VM
//action inputs:
// vm - VC:VirtualMachine
var nicsToDelete = [];
var changeVersion = vm.config.changeVersion;
var devices = vm.config.hardware.device;
for (var i in devices) {
if (isNic(devices[i])) {
@vmwarecode
vmwarecode / snippet.ps1
Created May 17, 2016 12:48
Remove all ESXi hosts from vCenter and readd them again.
#PowerCLI ****Remove all ESXi hosts from vCenter and readd them again.****
vSphere PowerCLI> $esx = get-vmhost
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> echo $esx
Name ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz MemoryUsageGB MemoryTotalGB Version
---- --------------- ---------- ------ ----------- ----------- ------------- ------------- -------
192.168.1.30 Connected PoweredOn 2 252 5600 3.727 4.000 5.5.0
10.0.0.30 Connected PoweredOn 4 1385 11196 3.725 4.000 5.5.0