Skip to content

Instantly share code, notes, and snippets.

@d4rkeagle65
d4rkeagle65 / Disable-Win10CDM.ps1
Created January 2, 2020 15:49
Small PowerShell script to disable Windows Content Delivery Management, allowing apps to be uninstalled permanently.
$reg_cdm = '\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
$keys = Get-Item -Path ("HKCU:"+$reg_cdm))
$keys.GetValueNames() | Foreach-Object {
If ($keys.GetValueKind($_) -eq 'DWord') {
Set-ItemProperty -Path ('HKCU:'+$reg_cdm) -Name $_ -Value 0 -Force
}
}
@d4rkeagle65
d4rkeagle65 / Quick-LDAPS-CertAuth.ps1
Last active September 14, 2022 16:21
Quick Setup of a Certificate Authority with a Certificate Template created and published to AD for Server Authentication to enable and allow for LDAPS to be setup.
# Some Sources:
#https://docs.microsoft.com/en-us/powershell/module/pkiclient/export-certificate?view=win10-ps
#https://powershell.org/forums/topic/certificate-templates-add-catemplate-problems/
#Run as Admin
$caName = "LDAPS-Server-Auth"
$cryptoProvider = "RSA#Microsoft Software Key Storage Provider"
$keyLength = 2048
$hashAlgorithm = 'SHA256'
@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
@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 / 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 / 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 / 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 / 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 / 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
((netsh wlan show interfaces) -Match '^\s+Signal' -Replace '^\s+Signal\s+:\s+','') -Replace '%',''