Skip to content

Instantly share code, notes, and snippets.

Working from home

Nick Shores nshores

Working from home
View GitHub Profile
View gist:115f39ab294bfe62439bfb4f1eb67992
foreach ($machine in $iplist){
$network = get-vm $machine.Parent | Invoke-VMScript -GuestUser $guestuser -GuestPassword $guestpassword -ScriptText "(gwmi Win32_NetworkAdapter -filter 'netconnectionid is not null').netconnectionid"
$NetworkName = $Network.ScriptOutput
$NetworkName = $NetworkName.Trim()
$machineipvalue = $machine.ip
$machinemaskvalue = $machine.mask
$machinegatewayvalue = $machine.GATEWAY
$machinedns1value = $machine.dns1
$machinedns2value = $machine.dns2
View set-cbt.ps1
# Enable CBT on virtual machines list
#Connect to vcenter
$vCenter = 'vcenter-pk-01.pkwillis.local'
$Creds = Get-Credential 'domain\userid' -Message 'Provide userid\password with permissions on VCenter'
if ($global:DefaultVIServers[0].name -match $vcenter){}
else{Connect-VIServer $vcenter -Credential $creds}
nshores / scp_copy.yaml
Created January 15, 2018 23:05
Ansible SCP Copy
View scp_copy.yaml
- name: Copy file over SCP
hosts: SCLH
gather_facts: no
connection: local
#SSHPass is required on the local host running this playbook to pass a SSH passoword.
nshores / schedule_junos_event.junos
Created January 17, 2018 04:46
Schedule command to run every day at time.
View schedule_junos_event.junos
set event-options generate-event FirmwareUpgrade time-of-day "22:00:00 +0000"
set event-options policy Firmwareupgrade events FirmwareUpgrade
set event-options policy Firmwareupgrade then execute-commands commands "request system software add /var/tmp/jinstall-ex-2200-15.1R6.7-domestic-signed.tgz reboot"
nshores / vswitch-to-dvs.ps1
Created January 29, 2018 20:34
View vswitch-to-dvs.ps1
# ESXi hosts to migrate from VSS->VDS
$vmhost_array = @("RMIESXI01.rci.local", "RMIESXI02.rci.local", "RMIESXI03.rci.local", "RMIESXI04.rci.local", "RMIESXI05.rci.local", "RMIESXI06.rci.local")
# Create VDS Switches
$vds_name = "VDS-Production"
Write-Host "`nCreating new VDS" $vds_name
New-VDSwitch -Name $vds_name -Location (Get-Datacenter)
nshores / svmotion.ps1
Last active April 10, 2018 08:59
vSphere Compute/Storage/VDS Migration
View svmotion.ps1
$vms = Get-VM
foreach ($vm in $vms) {
write-host "Moving $($ Compute"
$vm | move-vm -destination rmiesxi01.rci.local
write-host "Moving $($ Disks"
Get-HardDisk -VM $ | % { Move-HardDisk $_ -Datastore ($_.Filename -replace '\[NS(.+?)\].*', 'NS2$1') -Confirm:$false }
nshores / Convert-SonicWALLexp.ps1
Created February 26, 2018 23:26
View Convert-SonicWALLexp.ps1
function Convert-SonicWALLexp ($FilePath,$OutFile=("$($FilePath.Substring(0,$FilePath.Length - 4)).txt"))
$tempFile = ".\asdfadasasdfawefasdfawef"
(Get-Content $FilePath) -replace ".{2}$" | Out-File -Encoding default -FilePath "$($tempFile).exp"
$arguments = @("-decode","$($tempFile).exp","$($tempFile).txt")
& certutil.exe $arguments
(Get-Content "$($tempFile).txt") -replace '\&',"`n" | Out-File $OutFile
Remove-Item "$($tempFile).txt"
Remove-Item "$($tempFile).exp"
nshores / Untitled-1
Created April 3, 2018 21:51
View Untitled-1
#Requires Chromedriver
#Google Chrome
#PhantomJS (Be sure to include in your path)
#USPS Informed Delivery Account
import myusps
# Establish a session.
username = ""
nshores / create_vm.ps1
Last active June 8, 2018 22:23
View create_vm.ps1
#Make sure you are connected to vCenter
$vcenter = 'rgavc2'
$serverlist = $global:DefaultVIServer
if($serverlist -eq $null) {
write-host "Connecting to $vcenter"
connect-viserver -Server $vcenter
#User Configurtable Parmaters. Include each VM and it's associated IP in the list below.
$vmlist = @{"" = "temp3"}
nshores /
Last active April 8, 2018 17:01
#Requires Chromedriver
#Google Chrome
#PhantomJS (Be sure to include in your path)
#USPS Informed Delivery Account
#Python3.6.5 (For f-strings)
#Register imgur client here -
#requires imgurpython
#requires setting up slack app integration