Skip to content

Instantly share code, notes, and snippets.

Chris Nakagaki Zsoldier

View GitHub Profile
@Zsoldier
Zsoldier / Get-SSLCert.ps1
Created Oct 31, 2018
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.
View Get-SSLCert.ps1
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 / PowerShellRestEndPoint.ps1
Last active Aug 29, 2018
Expands upon the example that Kamal of hkeylocalmachine.com posted on. Script is majority the same, but this example would let you define not only GETs, but POSTS and transform something like a json input into a PS Object to work against. Same caveats still apply related to security, but fascinating nonetheless.
View PowerShellRestEndPoint.ps1
# Reference: http://hkeylocalmachine.com/?p=518
# Create a listener on port 7000
$listener = New-Object System.Net.HttpListener
$listener.Prefixes.Add('http://+:7000/')
$listener.Start()
'Listening ...'
# Run until you send a GET request to /end
while ($true) {
$context = $listener.GetContext()
@Zsoldier
Zsoldier / Get-CDPorLLDPInfofromESXi.ps1
Last active May 14, 2018
Get-CDP or LLDP Info from ESXi/vCenter
View Get-CDPorLLDPInfofromESXi.ps1
function Get-CDPorLLDP {
$myCol = @()
foreach ($VIServer in $global:DefaultVIServers)
{
$vmhosts = Get-VMHost -Server $VIServer | where-object {$_.ConnectionState -eq "Connected" -or "Maintenance"}
foreach ($vmhost in $vmhosts)
{
Write-Host "Collating information for $($VMHost.Name)"
$networkSystem = Get-view -Server $viserver -Id $vmhost.extensiondata.ConfigManager.NetworkSystem
foreach($pnic in $networkSystem.NetworkConfig.Pnic)
View Get-NSXFirewallReport.ps1
<# Uncomment if you'd like to use. These are assumed and needed for custom report to work. Must be connected to vCenter and NSXMgr.
Import-Module vmware.powercli,powernsx
$Creds = Get-Credential -Message "Provide vCenter Admin credentials"
$vCenterNameorIP = Read-Host "Provide name or IP of vCenter"
Connect-VIServer $vCenterNameorIP -Credential $Creds
Connect-NSXServer -vCenterServer $vCenterNameorIP -Credential $Creds
#>
$DFWRules = Get-NSXFirewallRule
$CustomReport = @()
View get-vmhostwsmaninstance.ps1
function Get-VMHostWSManInstance {
param (
[Parameter(Mandatory=$TRUE,HelpMessage="VMHosts to probe")]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl[]]
$VMHost,
[Parameter(Mandatory=$TRUE,HelpMessage="Class Name")]
[string]
$class,
@Zsoldier
Zsoldier / Delete-vSANDiskgroup.ps1
Last active Oct 19, 2017
Delete a vSAN Disk Group Forcefully
View Delete-vSANDiskgroup.ps1
<#
Author: K. Chris Nakagaki
Source: tech.zsoldier.com
Use at your own risk, simply listed here for demonstration purposes to use how you see fit.
#>
<# Get the host w/ problem disk group #>
$VMhost = Get-VMHost NameofHostwithProblemDiskGroup
<# ESXCLI Connection #>
@Zsoldier
Zsoldier / Get-vCenterScheduledTasks.ps1
Created Sep 20, 2017
Example showing how to get/set scheduled tasks in vCenter/vSphere using PowerCLI
View Get-vCenterScheduledTasks.ps1
function Get-vCenterScheduledTask{
<#
.SYNOPSIS
Retrieve vCenter Scheduled Tasks.
.DESCRIPTION
Retrieve vCenter Scheduled Tasks.
.NOTES
Source: Automating vSphere Administration
Authors: Luc Dekens, Arnim van Lieshout, Jonathan Medd,
Alan Renouf, Glenn Sizemore
@Zsoldier
Zsoldier / Migrateto-VDSwitch.ps1
Created Sep 18, 2017
Moving connected physical nics and vmk's on ESXi host to DVS/VDS.
View Migrateto-VDSwitch.ps1
<#
You can target a single host or set of hosts. Made to only move 'management' vmk's.
Idea is that you would create vmotion, vsan, etc. vmk's after on VDS/DVS
#>
$VMhost = Get-VMHost "NameofHost"
<#
If you haven't created a vDSwitch yet, you can do so by replacing get-vdswitch with New-VDSwitch
$TargetVDS = New-VDSwitch -Name -Location (get-datacenter "nameofvirtualdatacenter")
$TargetPG = New-VDPortgroup -vdswitch $TargetVDS -Name "Whatevernameyouwant" -VLANID <# Replace if applicable #>
#>
@Zsoldier
Zsoldier / GeekToolGeekweather.sh
Created Jun 29, 2016
Bash script that can be used in GeekTool to generate geekweather2 geeklet image that is placed in /tmp/ directory. This particular version utilizes a python script to return city friendly name since.
View GeekToolGeekweather.sh
LAT="$(~/Dropbox/LocateMe/LocateMe -f "{LAT}")"
LON="$(~/Dropbox/LocateMe/LocateMe -f "{LON}")"
city=$(python ~/Dropbox/GeekTool/cityLocator.py $LAT $LON)
~/Dropbox/GeekTool/Geekweather2.sh -A $LAT -O $LON -n $city -u UK
@Zsoldier
Zsoldier / citylocator.py
Created Jun 29, 2016
Simple Python script that returns city name from provided longitude and latitude variables from bash. Uses geopy module and appears to work both on Python 2 and 3. City return may or may not be accurate. Kind of guessing by selecting 3rd return record from google and selecting first entry in comma separated return. Needs work obviously.
View citylocator.py
#!/usr/bin/python
import sys
def cityinfo(lat, lon):
from geopy.geocoders import GoogleV3
locator = GoogleV3()
address = locator.reverse([lat, lon])
city = address[3].address.split(",")[0]
print(city.replace(" ", ""))
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.