Skip to content

Instantly share code, notes, and snippets.

View jcefoli's full-sized avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / file_datetime.ps1
Created May 10, 2023 15:58
File DateTimeStamp Output
$outputFileName = "C:\Temp\File_{0:yyyyMMdd}_{0:HHmmss}.csv" -f (Get-Date)
#C:/Temp/File_20230510_115723.csv
@jcefoli
jcefoli / lolbanner.sh
Last active July 30, 2024 04:36
LolBanner Setup Script (Debian) - Create colorful text banners using the 3d.flf font, figlet and lolcat (wrapped by a bash function called lolcat)
#!/usr/bin/env bash
sudo apt install figlet lolcat --no-install-recommends -y
mkdir -p ~/.local/share/fonts
wget https://raw.githubusercontent.com/xero/figlet-fonts/master/3d.flf -P ~/.local/share/fonts/
cat << 'EOF' >> ~/.bashrc
# Function to display a banner using figlet and lolcat
@jcefoli
jcefoli / Update-SessionEnvironment.ps1
Created January 27, 2023 19:53
Refresh Path In Powershell Session Using Chocolatey
# Use chocolatey to refresh the path
Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1"
Update-SessionEnvironment -Full
@jcefoli
jcefoli / pwshIntellisense.ps1
Created December 19, 2022 17:05
Powershell Intellisense
## https://devblogs.microsoft.com/powershell/psreadline-2-2-6-enables-predictive-intellisense-by-default ##
# Get Configuration
Get-PSReadLineOption
## Get Intellisense Option
(Get-PSReadLineOption).PredictionSource
# Command History Path
(Get-PSReadLineOption).HistorySavePath
@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