Skip to content

Instantly share code, notes, and snippets.

@rmorimoto4
rmorimoto4 / hosts-shutdown.sh
Created October 8, 2023 00:49
Shutdown of all VMs on the specified host and host
#!/bin/zsh
# Setting env
export GOVC_URL=<vCenter FQDN>
export GOVC_USERNAME=XXXXX
export GOVC_PASSWORD=XXXXX
export GOVC_INSECURE=true
# Add host names you want to shutdown
host_names=("ESXi FQDN#1" "ESXi FQDN#2" "ESXi FQDN#3" "ESXi FQDN#4")
@tdewin
tdewin / manage.sh
Last active September 26, 2024 17:33
GOVC wrapper on Mac, install vmrc for remote console and imagemagick for cropping. Useful mainly for a lab
#!/bin/zsh
export PATH=$PATH:/Users/$(whoami)/go/bin/
export GOVC_URL=https://192.168.
export GOVC_USERNAME=root
export GOVC_PASSWORD=Pleaseshareallyourcredentialsongithubnow!
export GOVC_INSECURE=true
export DEF_SSH_USER=root
@fnky
fnky / ANSI.md
Last active April 28, 2025 14:23
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@chrodriguez
chrodriguez / vsphere-vms-without-autostart.sh
Created July 30, 2018 15:54
vmware vsphere set autostart script
#!/bin/bash
set -eo pipefail
usage() {
if [ ! -z "$1" ]; then
echo -e "ERROR:\n" 1>&2
echo -e "\t$@"
echo
fi
@kwilczynski
kwilczynski / environment.sh
Last active September 26, 2024 17:33
Using govc to add ExtraConfig setting to a virtual machine in VSphere.
export GOVC_URL=''
export GOVC_USERNAME=''
export GOVC_PASSWORD=''
# Disabled. Only use if TLS is completely broken.
# export GOVC_INSECURE=1
export GOVC_TLS_CA_CERTS=$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE' 2>/dev/null)
@raspi
raspi / esxi_lldp_control.sh
Last active January 11, 2023 15:35
Enable/Disable LLDP on VMWare ESXi. Requires SSH access to ESXi. Doesn't require vCenter.
#!/bin/sh
# Enable/Disable LLDP on vSwitch ports on VMWare ESXi
# Tested with ESXi 6.0.0 3620759
# Doesn't need vCenter, only SSH access to the ESXi machine
# (c) Pekka "raspi" Jarvinen 2016 http://raspi.fi/
SWITCH=$1
OPERATION=$2
if [ "$SWITCH" = "" ] || [ "$OPERATION" = "" ]; then
@AnthonyWC
AnthonyWC / vswitch-lldp.sh
Created March 3, 2016 19:10
Enable vSwitch LLDP for all VMNIC interfaces
VSISH_VSWITCH_PATH=/net/portsets
for vSwitch in $(vsish -e ls ${VSISH_VSWITCH_PATH});
do
VSWITCH=$(echo ${vSwitch} | sed 's/\///g')
for port in $(vsish -e ls ${VSISH_VSWITCH_PATH}/${vSwitch}ports);
do
PORT=$(echo ${port} | sed 's/\///g')
PORTINFO=$(vsish -e get ${VSISH_VSWITCH_PATH}/${vSwitch}ports/${port}status | sed 's/^[ \t]*//;s/[ \t]*$//');
CLIENT=$(echo ${PORTINFO} | sed 's/ /\n/g' | grep "clientName:" | awk -F ":" '{print $2}')
MACADDRESS=$(echo ${PORTINFO} | sed 's/ /\n/g' | grep "unicastAddr:" | uniq | sed 's/unicastAddr://;s/\(.*\)./\1/')

Using aws-cli and jq

list all instances for all ASGs

aws autoscaling describe-auto-scaling-instances \
  | jq '.AutoScalingInstances[] | {AutoScalingGroupName, InstanceId}'

list instance IDs for a particular ASG

@hummus
hummus / gist:8592113
Last active September 26, 2024 01:29
aws cli + jq example
wget http://stedolan.github.io/jq/download/linux64/jq
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \
"Name=instance-state-name,Values=running" \
| jq -r \
".Reservations[] | .Instances[] | .InstanceId" \
aws ec2 describe-volumes --filters \
"Name=status,Values=available" \
| jq -r ".Volumes[] | .VolumeId" \