Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Nakagaki Zsoldier

View GitHub Profile
@Zsoldier
Zsoldier / osx-pw-policies.sh
Created Nov 15, 2022 — forked from Freccia/osx-pw-policies.sh
Sets Os X Password Policies
View osx-pw-policies.sh
#!/bin/sh
###################################################################################
## Create a pwpolicy XML file based upon variables and options included below.
## Policy is applied and then file gets deleted.
## Use "sudo pwpolicy -u <user> -getaccountpolicies"
## to see it, and "sudo pwpolicy -u <user> -clearaccountpolicies" to clear it.
##
## Tested on: OS X 10.10 10.11 10.12
####################################################################################
@Zsoldier
Zsoldier / SkipQuickStart.ps1
Created Oct 11, 2022
Demonstrates creating a cluster w/ quickstart disabled or skipping quickstart on an already deployed cluster.
View SkipQuickStart.ps1
#Creates a simple cluster object in vCenter Inventory with quickstart disabled.
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$spec.InHciWorkflow = $false #Disables QuickStart
$_this = Get-View -Id 'Folder-group-h5'
$_this.CreateClusterEx($name, $spec)
#Disables QuickStart on an existing cluster
$Cluster = Get-Cluster "SomeCrazyName"
$Cluster.ExtensionData.AbandonHciWorkflow()
@Zsoldier
Zsoldier / Delete-NSXTOrphanedPorts.ps1
Created Oct 7, 2022
Automated Method to delete orphaned ports.
View Delete-NSXTOrphanedPorts.ps1
$NSXMgr = Read-Host "Enter NSX Manager IP or DNS name:"
$Creds = Get-Credential -Message "Enter NSX username and password"
$PortData = @()
$Segments = Invoke-RestMethod -Authentication Basic -Credential $creds -Method Get -Uri "https://$NSXMgr/policy/api/v1/infra/segments/" -SkipCertificateCheck:$true
Foreach ($Segment in $Segments.results){
$Ports = Invoke-RestMethod -Authentication Basic -Credential $creds -Method Get -Uri "https://$NSXMgr/policy/api/v1/infra/segments/$($Segment.id)/ports/" -SkipCertificateCheck:$true
$PortData += $Ports.results
While (!([string]::IsNullOrEmpty($Ports.cursor))){
@Zsoldier
Zsoldier / DeleteNSXTRouteFilter.sh
Created Jan 14, 2022
A way to forcefully delete a route advertisement filter in NSX-T. Use w/ extreme caution.
View DeleteNSXTRouteFilter.sh
echo -n Enter NSX Manager IP:
read nsxmgr
echo -n Enter NSX Manager admin password:
read -s secret
# The below curl command will display logical router id's and display names for those id's.
curl -k -u admin:$secret https://$nsxmgr/api/v1/logical-routers/ | awk -F ': ' '/"id"/{print substr($2,2, length($2)-3)} /"display_name"/{print substr($2,2, length($2)-3)}'
echo -n Enter target router id:
read routerid
@Zsoldier
Zsoldier / NewNSXTApplianceCerts.sh
Created Jan 14, 2022
Generate a CSR w/ SAN entries using NSX-T API's for your manager appliances, self-sign, and apply them.
View NewNSXTApplianceCerts.sh
# These values are unique to your environment.
# DO NOT USE this code if your NSX-T instance is managed by a service provider.
# You risk breaking your SLA/contracts/blahblahblah and yourself.
NSXMgr=IPorDNSNameofyourNSXManager
domainsuffix=zsoldier.com
org=zsoldiernet
orgunit=blog
country=US
state=GA
locality=ATL
@Zsoldier
Zsoldier / Add-NSXVMTags.ps1
Last active Aug 20, 2021
NSX-T 3.x+ VM/Virtual Machine Tag Management
View Add-NSXVMTags.ps1
#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 Jul 12, 2021
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.
View Get-NSXTVirtualMachineData.ps1
$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 / getnsxt0bgproutes.sh
Created Mar 24, 2021
Gets NSX-T BGP Route Table via curl and jq.
View getnsxt0bgproutes.sh
#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 / Get-NSXT0BGPRouteTable.ps1
Created Mar 10, 2021
Get BGP route table information from NSX-T T0.
View Get-NSXT0BGPRouteTable.ps1
$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 Mar 3, 2021
How to run several diskspd instances.
View run-diskspd.ps1
$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"