Skip to content

Instantly share code, notes, and snippets.

View Zsoldier's full-sized avatar

Chris Nakagaki Zsoldier

View GitHub Profile
@Zsoldier
Zsoldier / Add-NSXVMTags.ps1
Last active August 20, 2021 14:19
NSX-T 3.x+ VM/Virtual Machine Tag Management
#Requires -Module vmware.powercli
$Credential = Get-Credential
$skipcertcheck = $true
$AuthMethod = “Basic”
$NSXMgr=”0.0.0.0”
$apiendpoint = "/api/v1/fabric"
$base_url = ("https://" + $NSXMgr + $apiendpoint)
$tag = "Naka"
$scope = "NakaScope" # If scope not required, simply define as $null or ""
$vmnamefilter = "nakabuntu" # Not required. Will loop through all VM's otherwise.
@Zsoldier
Zsoldier / Get-NSXTVirtualMachineData.ps1
Created July 12, 2021 15:44
Someone was looking for a way to find 'Tagless' NSX-T VMs. Seems like the NSX-T realized state endpoint was the way to go.
$Credential = Get-Credential
$skipcertcheck = $true
$AuthMethod = “Basic”
$NSXMgr=”NSXTManagerIPorDNSName”
$policyapi = "/policy/api/v1"
$base_url = ("https://" + $NSXMgr + $policyapi)
$endpoint = "/infra/realized-state/virtual-machines"
$Data = Invoke-restmethod -Uri ($base_url + $EndPoint) -Method GET -Credential $Credential -SkipCertificateCheck:$skipcertcheck -Authentication:$AuthMethod
@Zsoldier
Zsoldier / Set-NSXTSegmentProfiles.ps1
Last active July 9, 2021 18:57
Example on how to change segment discovery, qos, and security profiles enmasse.
#Change Segment Profiles
$Credential = Get-Credential
$skipcertcheck = $true
$AuthMethod = “Basic”
$NSXMgr=”IPorDNSName”
$policyapi = "/policy/api/v1"
$base_url = ("https://" + $NSXMgr + $policyapi)
#Change these to the name of the various profiles you want to remap all your segments to.
$TargetIPDPName = "default-ip-discovery-profile"
@Zsoldier
Zsoldier / Get-SSLCert.ps1
Last active April 28, 2021 14:48
Allows you to pull down a remote systems SSL certificate regardless of whether it's trusted or not. This was made for Powershell Core, so should work on any platform than runs PS Core. No ServicePoint required. Specifically created to pull down and convert a vCenter's SSL Cert and convert to SHA256 thumbprint for registration to NSX-T.
Function Get-SSLCert{
[CmdletBinding()]
<#
.SYNOPSIS
Gets SSL certificate of remote system.
.DESCRIPTION
Gets SSL certificate of remote system in order to get it's thumbprint.
.EXAMPLE
Get-SSLCert tech.zsoldier.com
Returns the certificate as object.
@Zsoldier
Zsoldier / getnsxt0bgproutes.sh
Created March 24, 2021 14:51
Gets NSX-T BGP Route Table via curl and jq.
#Have not figured out how to have jq output an array for bash to loop through.
nsxt=DNSnameORIPAddressofNSXTManager
username=admin
password='superduperSecure!'
endpoint='policy/api/v1'
#Checks to see if you have jq installed.
if ! command -v jq &> /dev/null
then
echo "jq is needed for code for below code to work. Download or use brew/apt/packagemanager to install. https://stedolan.github.io/jq/"
exit
@Zsoldier
Zsoldier / ClearNSXTDNSCache.sh
Last active March 15, 2021 14:24
Curl method to force clear NSX-T DNS cache.
nsxt=iporDNSnameofNSXManager
username=admin
password=''
if ! command -v jq &> /dev/null
then
echo "jq is needed for code for below code to work. Download or use brew/apt/packagemanager to install. https://stedolan.github.io/jq/"
exit
fi
@Zsoldier
Zsoldier / Get-NSXT0BGPRouteTable.ps1
Created March 10, 2021 03:00
Get BGP route table information from NSX-T T0.
$NSXMgr = Read-Host "Please provide NSX-T DNS name or IP address."
$Credential = Get-Credential -Message "Please provide NSX-T username and password."
$skipcertcheck = $true
$AuthMethod = “Basic”
$policyapi = "/policy/api/v1"
$base_url = ("https://" + $NSXMgr + $policyapi)
$endpoint = "/infra/tier-0s/"
@Zsoldier
Zsoldier / run-diskspd.ps1
Created March 3, 2021 14:18
How to run several diskspd instances.
$testtimer=1800
$writepct=50
$blocksize='64k'
$threads=4
$outstandingio=16
$warmuptime=5
$filesize="10G"
$drives=@('D','E','F','G')
#$drives=@('E')
$diskspdpath = "C:\Users\Administrator\Downloads\DiskSpd\amd64\diskspd.exe"
@Zsoldier
Zsoldier / get-esxipcideviceinfo.ps1
Last active January 14, 2021 17:43
PowerCLI: Getting HCL DID, VID, and SVID information.
#Requires -Modules vmware.powercli
$esxihost = "DNSorIPofESXihost"
$vmhost = get-vmhost $esxihost
$vmhostcli = $vmhost | get-esxcli -v2
$pcidevices = $vmhostcli.hardware.pci.list.invoke()
#$pcidevices | where {$_.vendorname -match "Mellanox"}
$HCLData = @()
Foreach ($pcidevice in $pcidevices){
@Zsoldier
Zsoldier / Get-AzureGlobalReachEnabledERCircuits.ps1
Last active August 7, 2020 14:20
Gather ExpressRoute Circuits with Global Reach enabled. This does account for multiple subscriptions as well.
#Requires -Modules az
Connect-AzAccount
$ERGREnabled = @()
$GRDataFull = @()
$ERCircuits = @()
$Subs = Get-AzSubscription
Foreach ($Sub in $Subs){
Select-AzSubscription $Sub
$ERCircuits += Get-AzExpressRouteCircuit
}