Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / Update-SessionEnvironment.ps1
Created January 27, 2023 19:53
Refresh Path In Powershell Session Using Chocolatey
View Update-SessionEnvironment.ps1
# 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
View pwshIntellisense.ps1
## 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)
View dns-cluster-permissions.ps1
# 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
View iisHeaders.ps1
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 January 19, 2023 18:22
Set WSL Version
View wsl_helper.ps1
#Check WSL Version
wsl -l -v
#Set WSL Version to 2
wsl --set-version Ubuntu-22.04 2
@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)
View su-gitlab-runner.sh
sudo su -l gitlab-runner -s /bin/bash
@jcefoli
jcefoli / retry.sh
Created December 6, 2021 19:44
Powershell Retry Logic
View retry.sh
Begin {
$retryCount = 0
$retryMax = 5
$retryPauseSeconds = 30
}
Process {
do {
$retryCount++
try {
@jcefoli
jcefoli / ubuntu_cleanup.sh
Created December 3, 2021 05:20
Ubuntu Cleanup (WIP)
View ubuntu_cleanup.sh
sudo apt autoremove --purge
# Remove logs
sudo -s
sudo rm -rf /var/log/*.gz
sudo rm -rf /var/log/apt/*.gz && sudo rm -rf /var/log/apt/*.xz
sudo rm -rf /var/log/installer/*.gz
@jcefoli
jcefoli / nopasswd_sudo.sh
Created October 11, 2021 04:50
Remove password prompt from sudo elevation, with paranoia checks (Ubuntu 20.04 LTS)
View nopasswd_sudo.sh
#!/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
View web.config
<?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>