Skip to content

Instantly share code, notes, and snippets.

View dapacruz's full-sized avatar

David Cruz dapacruz

View GitHub Profile
@dapacruz
dapacruz / Remove-Datastores.ps1
Last active June 19, 2018 21:45
Remove VMware vSphere Datastores
break
$eql_group_addr = '1.1.1.1'
$eql_user = 'grpadmin'
$vcenter_addr = 'vcenter.domain.loc'
$vcenter_user = 'administrator@vsphere.local'
$vmhosts = '*'
$creds = Get-Credential -UserName $vcenter_user -Message 'Enter Password'
Connect-VIServer -Server $vcenter_addr -Credential $creds
@dapacruz
dapacruz / Get-ComputerIPv4NetworkInfo.ps1
Last active June 20, 2018 15:32
Get Windows Computer IPv4 Network Information
$hostname = 'localhost'
Get-WmiObject -ComputerName $hostname -Class win32_networkadapterconfiguration |
select PSComputerName, Description, MacAddress, @{n='IPAddress'; e={$_.IPAddress -match "(\d{1,3}\.){3}\d{1,3}"}}, DHCPEnabled, @{n='DefaultIPGateway'; e={$_.DefaultIPGateway -match "(\d{1,3}\.){3}\d{1,3}"}}, DNSDomain, ServiceName |
? {$_.MacAddress -and $_.IPAddress}
@dapacruz
dapacruz / Generate-VMwareVsphereDocumentation.ps1
Last active August 17, 2018 17:17
Generate VMware vSphere Documentation
# Host CPU ratio
Get-VMHostCpuRatio | Export-Csv -NoTypeInformation 'VMware Host CPU Ratio.csv'
# Host datastores
Get-VMHostDatastores | Export-Csv -NoTypeInformation 'VMware Host Datastores.csv'
# Host CDP/LLDP info
Get-VMHostNetworkCdpInfo | Export-Csv -NoTypeInformation 'VMware Host CDP Info.csv'
Get-VMHostNetworkLldpInfo | Export-Csv -NoTypeInformation 'VMware Host LLDP Info.csv'
@dapacruz
dapacruz / Validate-VMhostNetworking.ps1
Last active July 12, 2018 21:22
Validate VMware vSphere Host Networking
# Test ESXi Host Networking
$vmhosts = 'test_esxi-01.domain.net', 'test_esxi-02.domain.net'
$mgmt_vmks = 'vmk0'
$mgmt_addrs = Get-VMHostNetworkAdapter -VMHost $vmhosts -Name $mgmt_vmks | select -ExpandProperty IP
$vmotion_vmks = 'vmk2', 'vmk3'
$vmotion_addrs = Get-VMHostNetworkAdapter -VMHost $vmhosts -Name $vmotion_vmks | select -ExpandProperty IP
@dapacruz
dapacruz / Watch-Device.ps1
Last active July 19, 2018 14:54
Monitor a Device During a Reboot and Receive a Text-to-Speech Notification When it is Back Online
# Monitor a device during a reboot and receive an text-to-speech notification when it is back online
# Requires PowerShell Community Extensions (Install-Module -Name PSCX)
$ip_address = '8.8.4.4'
while (-not (Test-Connection -ComputerName $ip_address -Quiet -Count 1)) {sleep 5}; Out-Speech "Host $ip_address is back online!"
@dapacruz
dapacruz / Recover-VM.ps1
Last active July 23, 2018 17:13
Recover Virtual Machine
break
$vmhost = '*'
$vcenter = 'vcenter.domain.local'
$vcenter_user = 'administrator@vsphere.local'
$guest_creds = Get-Credential 'administrator'
# Save an encrypted password to a file and retrieve it later for use in a script
# Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File vc_password.txt
$vcenter_password = Get-Content 'vc_password.txt' | ConvertTo-SecureString
@dapacruz
dapacruz / Get-IscsiDiskInfo.ps1
Last active September 20, 2018 16:26
Get iSCSI Disk Information
$output = "$($env:TEMP)\iSCSI_Disks.csv"
$results = @()
$disk = Get-Disk | Where-Object {$_.BusType -eq 'iSCSI'} | Sort-Object -Property Number
foreach ($d in $disk) {
$partition = Get-Partition -DiskNumber $d.Number
$iscsi_session = Get-IscsiSession -Disk $d
$obj = New-Object -TypeName PSObject
Add-Member -InputObject $obj -MemberType NoteProperty -Name DiskNumber -Value $d.Number
@dapacruz
dapacruz / Watch-DomainControllers.ps1
Last active March 26, 2025 17:30
Watch Active Directory Domain Controllers for Adds and Removes
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$path = $PSScriptRoot
$reference_path = "$path\Domain_Controllers-Last.csv"
$difference_path = "$path\Domain_Controllers-Latest.csv"
$report_path = "$path\AD-DC-Changes-$(Get-Date -UFormat %m%d%Y).csv"
Start-Transcript -Path "$path\log.txt" | Out-Null
$domain_controllers_reference = Import-Csv -Path "$reference_path"
@dapacruz
dapacruz / Build-GoSource.ps1
Last active August 19, 2021 16:47
Compile Go Apps for Multiple Platforms
<#
.Synopsis
Compile Go Apps for Multiple Platforms
.Parameter Platform
Platforms to compile for
.Notes
Developed by David Cruz
.Example
$ Build-GoSource.ps1 -Platform Windows-AMD64, Darwin-AMD64, Linux-AMD64
#>
@dapacruz
dapacruz / .env
Last active April 6, 2020 03:58
Docker TIG Stack
TELEGRAF_HOST=telegraf
INFLUXDB_HOST=influxdb
INFLUXDB_PORT=8086
INFLUXDB_DATABASE=metrics
INFLUXDB_ADMIN_USER=grafana
INFLUXDB_ADMIN_PASSWORD=password
GRAFANA_PORT=3000
GRAFANA_USER=admin