Skip to content

Instantly share code, notes, and snippets.

@d4rkeagle65
d4rkeagle65 / checksumGenerator.bat
Created July 8, 2020 13:09
Checksum Generator with certutil, takes file path as command line argument
@Echo off
:: Pass the file to hash as the only arg
Set "MD5="
For /f "skip=1 Delims=" %%# in (
'certutil -hashfile "%~f1" MD5'
) Do If not defined MD5 Set MD5=%%#
Set MD5=%MD5: =%
Echo:%MD5%
select schema_name(tab.schema_id) as schema_name,
tab.name as table_name,
col.column_id,
col.name as column_name,
t.name as data_type,
col.max_length,
col.precision
from sys.tables as tab
inner join sys.columns as col
on tab.object_id = col.object_id
((netsh wlan show interfaces) -Match '^\s+Signal' -Replace '^\s+Signal\s+:\s+','') -Replace '%',''
@d4rkeagle65
d4rkeagle65 / Invoke-WANDownloadSpeedTest.ps1
Last active June 23, 2020 15:06
Runs a speed test to the closest few speedtest.net servers and returns the highest result.
Function Invoke-SpeedTest {
param (
$Server
)
$topServerUrlSpilt = $Server -split 'upload'
$url = $topServerUrlSpilt[0] + 'random2000x2000.jpg'
$wc = New-Object system.net.WebClient
$wc.QueryString = New-Object System.Collections.Specialized.NameValueCollection
$downloadElaspedTime = (Measure-Command {$webpage1 = $wc.DownloadData($url)}).totalseconds
@d4rkeagle65
d4rkeagle65 / posh_sendSMTPEmail.ps1
Created June 9, 2020 16:05
Send an email with or without SSL via powershell.
# Sender and Recipient Info
$MailFrom = "[email protected]"
$MailTo = "[email protected]"
# Sender Credentials
$Username = ""
$Password = ""
# Server Info
$SmtpServer = ""
@d4rkeagle65
d4rkeagle65 / Get-OfflineEvents.ps1
Created May 21, 2020 14:06
Powershell script to get Sleep, Wake, Shutdown, Restart, Wireless/Wired Connection & Disconnect Events from the Eventlog. I will clean this up in the future, but wanted to record it quickly for the moment.
param( $Newest = 10 )
function Parse-EventLogEntry
{
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)]
[System.Diagnostics.EventLogEntry[]]
$eventInfo
)
@d4rkeagle65
d4rkeagle65 / ESXi-UpgradeTo6.7.0.sh
Created April 16, 2020 15:06
Run these commands on a VMWare vSphere host to upgrade it to 6.7.0
esxcli software sources profile list -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml | grep ESXi-6.7.0-20
vim-cmd /hostsvc/maintenance_mode_enter
esxcli network firewall ruleset set -e true -r httpClient
esxcli software profile update -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml -p ESXi-6.7.0-20191204001-standard
reboot
vim-cmd /hostsvc/maintenance_mode_exit
@d4rkeagle65
d4rkeagle65 / ESXi-QuickSNMPEnable.sh
Created April 16, 2020 15:04
Run these commands on an VMWare vSphere host to enable SNMP and restrict it to be accessed for read only by a IP address.
esxcli system snmp set --communities public
esxcli system snmp set --enable true
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address <IPAddress Of SNMP Manager>
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart
@d4rkeagle65
d4rkeagle65 / setup-pcap-trace.ps1
Last active April 6, 2020 16:27
Sets up a wireshark capture outputting to a file, using tshark and a windows service that can be started/stopped.
$svcName = "WiresharkPCAPTrace"
$outFile = "C:\ProgramData\WiresharkPCAPTrace.pcapng"
if (Get-Service -Name $svcName -ea SilentlyContinue) {
Write-Host "The pcap service has already been added to this system. Proceeding with removal and recreation"
$service = Get-WmiObject -Class Win32_Service -Filter "Name='$svcName'"
$service.Delete() | Out-Null
}
$fspace = Get-WMIObject -Class Win32_LogicalDisk | Where {$_.DeviceID -like "C:"} | Select @{Name="FreeSpaceGB"; Expression={[math]::round($_.FreeSpace/1GB, 2)}}
if ($fspace.FreeSpaceGB -lt "10.00") {
@d4rkeagle65
d4rkeagle65 / Quick-RDS-Server.ps1
Created March 19, 2020 21:45
Powershell script to setup a quick standalone RDS server.
# Install Powershell Modules
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-WindowsFeature RSAT-AD-PowerShell
# Install RDS Server Features
Add-WindowsFeature –Name RDS-Gateway –IncludeAllSubFeature
Add-WindowsFeature –Name RDS-Connection-Broker –IncludeAllSubFeature
Get-WindowsFeature | ? { $_.Name -match "RDS-Licensing|RDS-RD-Server" } | Install-WindowsFeature –IncludeAllSubFeature
# Set Firewall and Service Settings for RD