Skip to content

Instantly share code, notes, and snippets.

View gsmitheidw's full-sized avatar

Graham Smith gsmitheidw

View GitHub Profile
# Enable SNMP on ESXi 6.*
# Note: this is not secured SNMP3
#
esxcli system snmp set --communities Public
esxcli system snmp set --enable true
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address 192.168.1.0/24
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
@gsmitheidw
gsmitheidw / params.ps1
Created February 22, 2019 18:10
params example powershell
param (
[Parameter(Mandatory=$true)]
[string]$url = $( Read-Host "URL>")
)
youtube-dl.exe -x --audio-format mp3 --audio-quality 192K $url
@gsmitheidw
gsmitheidw / gist:eee830f2ba6ae301449d90a1ef5b7f0b
Last active April 26, 2018 13:30
vmware cheatsheet of useful commands
# From shell change appliance default to bash (needed for winscp transfers to vcenter)
chsh -s /bin/bash
# and back again with:
chsh -s /bin/appliancesh root
# May be pre-requisite to set shell.set --enable True in appliance root also depending on current settings
#Install certs (example: for intercepting proxy authentication):
/usr/lib/vmware-vmafd/bin/dir-cli trustedcert publish --chain --cert /path/to/cert.cer
# Note cert must be base64 encoded on export not DER encoded!
# View installed certs with /usr/lib/vmware-vmafd/bin/dir-cli trustedcert publish --chain --cert
@gsmitheidw
gsmitheidw / omsa-alert.ps1
Last active March 24, 2017 18:21
Setting OpenManage Alerts from powershell
<# This sends e-mails via smtp to a chosen address if an alert is triggered on a Dell Server system by OpenManage
# Pre-Requisites: Dell OpenManage installed, a mail server allowing smtp without authentication, omconfig on the system path
# or can be called by full path. Note: Dell omconfig alert action must be populated once per server with the list of commands
# at the end of this script
# Tested on 2008R2 and 2012R2
#>
param(
[string]$body
)
@gsmitheidw
gsmitheidw / chocolateyuninstall.ps1
Created November 22, 2016 15:06
packet tracer 7.0 chocolatey uninstall script
# contents of chocolateyuninstall.ps1
$app = "C:\Program Files\Cisco Packet Tracer 7.0\unins000.exe"
$arguments =" /SILENT"
start-process $app $arguments
@gsmitheidw
gsmitheidw / chocolateyinstall.ps1
Created November 22, 2016 15:06
packet tracer 7.0 chocolatey install script
# contents of chocolateyinstall.ps1
Install-ChocolateyPackage `
-PackageName 'packettracer' `
-FileType 'exe' `
-SilentArgs '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' `
#-Url '\\uncpath\packettracer\PacketTracer70_64bit_setup.exe' `
-Url64bit '\\uncpath\packettracer\PacketTracer70_64bit_setup.exe' `
-Checksum 'F0270A04BE880297D8B6B20DC7F3690D4063E8FFECED533A03D6D7BB21574624' `
#-Checksum64 'F0270A04BE880297D8B6B20DC7F3690D4063E8FFECED533A03D6D7BB21574624' `
# Create a vm from core-current.so - note vnc is used to "see" the guest and network:default means NAT not bridge
virt-install --name kvm1 \
--ram 128 \
--disk path=/var/lib/libvirt/images/kvm1.img,size=0.1 \
--network network:default \
--accelerate \
--vnc -c /opt/Core-current.iso
# Show running guests which kvm calls a domain
virsh list
#Send Keypresses
$wshell = new-object -com wscript.shell
$wshell.SendKeys("{CAPSLOCK}")
# Graphical input
$data = [Microsoft.VisualBasic.Interaction]::InputBox('hi user give me your data', 'inputboxtitle')
# Graphical output
[Microsoft.VisualBasic.Interaction]::MsgBox("tada", "OKOnly,SystemModal,Information", "msgboxtitle")
# Grab mp3 creates mp3s from youtube-dl in a format that works in more devices which may have issues with VBR etc
#
# Requires: chocolately from chocolately.org then run this commented out line in an escalated powershell prompt:
# cinst youtube-dl ffmpeg lame -y --allowEmptyChecksums # some of these don't currently have checksums enabled by their maintainers
# Probably best to put this script somewhere in your system path
# Set up graphical input/output
Add-Type -AssemblyName Microsoft.VisualBasic
$link = "" #null
$link = [Microsoft.VisualBasic.Interaction]::InputBox('Paste in youtube URL or playlist url', 'grab-mp3')
@gsmitheidw
gsmitheidw / btrfs.sh
Last active March 19, 2017 16:16
btrfs cheatsheet
btrfs filesystem df /mnt/edu/
btrfs dev stats /mnt/edu/
btrfs scrub start -c3 <mount point>
brtfs fi show
# Add a btfs device to an existing mountpoint then mirror it on the fly with balance.
btrfs device add -f /dev/sdb /media/usb1/
btrfs balance start -dconvert=raid1 -mconvert=raid1 /media/usb1/
# defrag
btrfs filesystem defragment /media/usb1/
# df