Skip to content

Instantly share code, notes, and snippets.

View jcefoli's full-sized avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / dns-cluster-permissions.ps1
Last active November 26, 2022 04:59
Windows Cluster / DNS: Assign Full Rights to Cluster, Listener and Computer Objects (Bug workaround)
# Get a listing of all clusters (CLUS)
$clusters = Get-ADComputer -Filter "Name -like 'CLUS'"
#Set Domain
$DNSServer = (Get-ADDomain).PDCEMulator
#Set DNS Zone
$DNSZone = "dev.contoso.com"
#Iterate through the list of clusters get dns and add the appropriate full control objects (listener, cluster)
@jcefoli
jcefoli / iisHeaders.ps1
Created September 16, 2022 21:40
IIS Header Examples
Import-Module WebAdministration
# Add Custom Header - Server Level
Add-WebConfigurationProperty -PSPath MACHINE/WEBROOT/APPHOST `
-Name . -Filter system.webServer/httpProtocol/customHeaders `
-AtElement @{name = "X-Custom" ; value = 'value' }
#Remove Server: Microsoft-IIS/10.0 Header
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/security/requestFiltering" -name "removeServerHeader" -value "True"
@jcefoli
jcefoli / wsl_helper.ps1
Last active May 10, 2024 04:03
Set WSL Version
# Check WSL Version
wsl -l -v
# Set WSL Version to 2
wsl --set-version Ubuntu-22.04 2
# Fix WSL2 Networking (per https://stackoverflow.com/a/65325532)
rm /etc/resolv.conf || true
rm /etc/wsl.conf || true
@jcefoli
jcefoli / su-gitlab-runner.sh
Created January 27, 2022 18:54
Login to Gitlab Runner (to initiate SSH connections and add server to known_hosts)
sudo su -l gitlab-runner -s /bin/bash
@jcefoli
jcefoli / retry.sh
Created December 6, 2021 19:44
Powershell Retry Logic
Begin {
$retryCount = 0
$retryMax = 5
$retryPauseSeconds = 30
}
Process {
do {
$retryCount++
try {
@jcefoli
jcefoli / ubuntu_cleanup.sh
Last active January 23, 2024 06:28
Ubuntu Cleanup (WIP)
sudo apt autoremove --purge
#Remove VSCode Server Space Hog Bullshit
rm -rf /home/jcefoli/.vscode-server
# Clean Journal BS
sudo journalctl --vacuum-size=100M
# Remove logs
sudo -s
@jcefoli
jcefoli / nopasswd_sudo.sh
Created October 11, 2021 04:50
Remove password prompt from sudo elevation, with paranoia checks (Ubuntu 20.04 LTS)
#!/usr/bin/env bash
cp --no-preserve=mode,ownership /etc/sudoers /etc/sudoers.tmp
sed -i "s/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL) NOPASSWD: ALL/g" /etc/sudoers.tmp
visudo -c -f /etc/sudoers.tmp
if [ "$?" -eq "0" ]; then
cp /tmp/sudoers.tmp /etc/sudoers
@jcefoli
jcefoli / web.config
Created August 12, 2021 17:54
Web Config to disable aggressive IIS caching for php development on Windows
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<urlCompression doStaticCompression="false" doDynamicCompression="false" />
<caching>
<profiles>
<add extension=".html" policy="DisableCache" kernelCachePolicy="DisableCache" />
<add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
<add extension=".txt" policy="DisableCache" kernelCachePolicy="DisableCache" />
</profiles>
@jcefoli
jcefoli / aws-ssm-param.ps1
Last active March 9, 2021 18:30
Powershell AWS CLI SSM Parameter Store Helper
<#
.SYNOPSIS
Helper script to manage SSM parameters
.PARAMETER name
SSM key name to set
.PARAMETER value
SSM key value to set
@jcefoli
jcefoli / keepaliveScheduler.ps1
Last active March 14, 2025 15:52
Script that creates a scheduled task to keep your RDP session alive to work around nonsensical GPOs that inhibit productivity
<#
.SYNOPSIS
Keeps you productive by spoofing activity to prevent GPO idle timeouts, RDP disconnects, sleep, etc.
.Description
This script creates a Scheduled Task that runs at login which uses Kernel SetThreadExecutionState to prevent GPOs
from disconnecting your RDP session. Will also prevent sleeping/screensavers/display timeouts
See the example below for a one liner that will download and execute this script directly from GitHub!