Skip to content

Instantly share code, notes, and snippets.

View tonysangha's full-sized avatar

Tony Sangha tonysangha

  • Cloudflare
  • Sydney Australia
View GitHub Profile
@tonysangha
tonysangha / find-ubuntu-ami.md
Created June 14, 2022 00:43
List the last 5 Ubuntu AMI Image builds in a specific AWS Region using the CLI

Find a list of Ubuntu AMI's in a specific region

aws ec2 describe-images --region us-east-1 \
 --filters Name=name,Values="ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server*" \
 --query 'Images[*].[ImageId,CreationDate,Description]' --output text \
 | sort -k2 -r \
 | head -n5
@tonysangha
tonysangha / NSXv-TOC.md
Last active March 11, 2022 21:22
Below is a list of links to NSX-v resources I have found useful, it is by no means complete and is a living list that I will update regularly
@tonysangha
tonysangha / vRNI_search_queries.markdown
Last active May 25, 2021 04:55
vRealize Network Insight Search Queries
@tonysangha
tonysangha / bubble_network_2.0.ps1
Created November 13, 2017 03:21
Updated script by Shane White
<#
Created by Tony Sangha
July 2017
tonysangha.com
version 0.1
Modified by Shane White
October 2017
Version 1.0
@tonysangha
tonysangha / PowerNSX_OneLiners.ps1
Last active September 29, 2017 15:04
One liners commands for PowerNSX
# Retrieve any rules that are configured with either block (deny) or reject in the NSX Distributed Firewall
Get-NsxFirewallSection | Get-NsxFirewallRule | ? {$_.action -eq "deny" -or $_.action -eq "reject"} | ft -autosize
# Retrieve services matching port number
get-nsxservice | ? {$_.element.value -eq "80"} | select name
# Compare NSX Services from two different NSX environments and list the differences based on name
# Not really a one liner I know
$old_services = Get-NsxService -Connection $old_env
$new_services = Get-NsxService -Connection $new_env
@tonysangha
tonysangha / bubble_network.ps1
Last active August 4, 2017 11:34
PowerNSX script to create a bubble network, consisting of Logical Switches, DLR, ESG and Firewall Rules
<#
Created by Tony Sangha
July 2017
tonysangha.com
version 0.1
####################################
macOS PowerCLI specific commands
Get-Module -ListAvailable PowerCLI* | Import-Module
@tonysangha
tonysangha / powercli#1.ps1
Created March 6, 2017 05:58
Get Hosts and VMs that belong to certain vSphere clusters using PowerCLI - (OR) Statement
$clusters = get-cluster
$clusters | Where-Object {$_.name -like "XXXXX" -OR $_.name -like "XXXXX"} | get-vmhost | select name, Manufacturer, Model, ProcessorType, NumCpu, Version, Build, Parent
$clusters | Where-Object {$_.name -like "XXXXX" -OR $_.name -like "XXXXX"} | get-vm
  • username: consoleuser
  • password: ark1nc0ns0l3
@tonysangha
tonysangha / get_mac_ipv.ps1
Last active December 12, 2016 04:05
Get MAC & IP using PowerCLI
$vms = get-vm
# Get VM Name based on a MAC
foreach ($vm in $vms){
if(get-networkadapter $vm | where-object {$_.MacAddress -eq "MAC-ADDRESS"})
{
write-host $vm
}
}
@tonysangha
tonysangha / NSX Controller Syslog Update.sh
Last active November 6, 2016 20:06
Update NSX-v Controller Syslog using a curl command from a bash shell
nsx_mgr = 192.168.110.10
user = admin
pass = VMware1!
for x in 1 2 3; do curl -u $user:$pass -H "Content-Type: application/xml" -X GET -k https://$nsx_mgr/api/2.0/vdn/controller/controller-$x/syslog ;done