Skip to content

Instantly share code, notes, and snippets.

View jcefoli's full-sized avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / iischeatsheet.bat
Last active January 20, 2023 18:25
IIS Websites and Apppools Delete/Import/Export Cheat Sheet
REM Delete all Websites
%windir%\system32\inetsrv\appcmd list site /xml | %windir%\system32\inetsrv\appcmd delete site /in
REM Delete all App Pools
%windir%\system32\inetsrv\appcmd list apppool /xml | %windir%\system32\inetsrv\appcmd delete apppool /in
REM Export all the Application Pools:
%windir%\system32\inetsrv\appcmd list apppool /config /xml > C:\apppools.xml
REM Import all the Application Pools:
@jcefoli
jcefoli / wsl_helper.ps1
Last active January 19, 2023 18:22
Set WSL Version
#Check WSL Version
wsl -l -v
#Set WSL Version to 2
wsl --set-version Ubuntu-22.04 2
@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 / allkeys.php
Last active November 21, 2022 11:11
List All Key/Value Pairs in Redis using the Predis Library. Assumes that Redis is running locally on default port 6379 with no password auth
<?
//Include Predis library. See https://github.com/nrk/predis for more info
require "Predis/Autoloader.php";
//Connect to Redis
Predis\Autoloader::register();
try {
$redis = new Predis\Client();
$redis = new Predis\Client(array(
"scheme" => "tcp",
@jcefoli
jcefoli / speedbot.py
Created February 1, 2016 07:06
Parse speedtest-cli results
#!/usr/bin/python
import os
import sys
# Simplified version of: http://www.engadget.com/2016/01/31/comcast-customer-complaint-bot/ aka http://pastebin.com/WMEh802V
# Removed the Twitter integration and file system logging
# To do: Add variables and math so the speeds are not hard coded and are based off a percent calculation
def speedbot():
#Run speedtest-cli (pip install speedtest-cli, assumes it's in your system path)
@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 / recursive_find_replace.ps1
Created January 10, 2018 17:01
Powershell Find/Replace: Recursively replace text in all *.config files in a directory using .NET
$configFiles = Get-ChildItem C:\YourDirectory *.config -Recurse
foreach ($file in $configFiles)
{
$content = [System.IO.File]::ReadAllText($file.FullName).Replace('foo','bar')
[System.IO.File]::WriteAllText($file.FullName, $content)
}
@jcefoli
jcefoli / centos6domainjoin.md
Last active May 9, 2022 01:37
Join CentOS 6 to Windows Domain

Join CentOS 6 VM to Domain

  1. Install Necessary Packages yum -y install authconfig krb5-workstation pam_krb5 samba-common oddjob-mkhomedir

  2. Set DNS Nameservers to Primary Domain Controller and Secondary View config like this cat /etc/resolv.conf and make sure the nameservers point at the domain controller IPs.

  3. Join Domain This will join the domain. It's multi-line for readability. You can copy/paste the whole thing into the terminal and it will work

@jcefoli
jcefoli / guid.ps1
Created February 17, 2016 14:45
Create GUID in Powershell (Uppecase String)
[guid]::NewGuid().toString().ToUpper()