Skip to content

Instantly share code, notes, and snippets.

View jcefoli's full-sized avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / move-recursive.ps1
Last active April 24, 2024 04:23
Powershell: Move Files & Folders In Directory Recursively to Another Directory
<#
Recursively move all files in C:\SourceDir into C:\Destination
Assumes C:\Destination exists already, or there could be problems
#>
Move-Item -Path "C:\SourceDir\*" -Destination "C:\Destination"
@jcefoli
jcefoli / Disable-AeroShake.ps1
Created September 3, 2019 15:53
Disable Aero Shake (Idiotic Windows feature that minimizes all windows if you shake one window with the mouse. I do this when I'm thinking sometimes inadvertently and it annoys the hell out of me)
#Run as Admin
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisallowShaking" -Value "0" -PropertyType "DWord"
@jcefoli
jcefoli / pkmnGoldEncounterModifier.ps1
Last active March 20, 2024 22:36
Generates Gameshark codes for Pokemon Gold/Silver/Crystal to encounter a specific Pokemon at a specific level
<#
.DESCRIPTION
Generates Gameshark codes for Pokemon Gold/Silver/Crystal to encounter a specific Pokemon at a specific level
Takes user input for the Pokemon name and level and generates the codes
#>
function ConvertTo-Hex {
param (
[Parameter(Mandatory=$true)]
[int]$Number
@jcefoli
jcefoli / timer.bat
Created August 28, 2014 14:37
This snippet calculates a start time, end time and total duration for your batch script
@ECHO off
SET STARTTIME=%TIME%
REM DO THINGS HERE TO TIME
timeout 5
REM DO THINGS HERE TO TIME
REM Final Calculations
@jcefoli
jcefoli / choice.bat
Created August 15, 2014 22:33
Template for Yes/No Choice input in batch files
@ECHO OFF
:start
SET choice=
SET /p choice=Do something? [N]:
IF NOT '%choice%'=='' SET choice=%choice:~0,1%
IF '%choice%'=='Y' GOTO yes
IF '%choice%'=='y' GOTO yes
IF '%choice%'=='N' GOTO no
IF '%choice%'=='n' GOTO no
IF '%choice%'=='' GOTO no
@jcefoli
jcefoli / tstWan.ps1
Last active January 27, 2024 09:49
Windows Sandbox Connection Tester & Reboot
# This will ping google to test for a WAN connection and reboot if it fails
# Workaround to my Windows Sandbox always losing network
# The weird logging to write-host/write-output is designed to be used with Windows task scheduler (interactive logon) or via console directly
$host.ui.RawUI.WindowTitle = "Network Checker"
Clear-Host
$dt = (get-date).toString()
Write-Host "Network Check Running. Logfile: C:\Users\$($env:username)\networkCheck.log"
Write-Output "[$dt] Network Check Running. Logfile: C:\Users\$($env:username)\networkCheck.log" | Out-File -FilePath "C:\Users\$($env:username)\networkCheck.log" -Encoding utf8 -Append
@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 / Run_SQL.ps1
Last active January 9, 2024 01:37
Loop Through Folder and Run all .sql Scripts Against a MSSQL Database
<#
.SYNOPSIS
Powershell Script that will loop through a folder and run SQL scripts against a database
.Description
This script was developed to be used with VSTS. It must accept parameters, since VSTS variables cannot be used within scripts. Developers can specify a different SQL folder with each build
.NOTES
Version: 1.0.1
Author: jcefoli
@jcefoli
jcefoli / SaveSpotlightImages.ps1
Last active December 30, 2023 18:34
Copies the Windows Spotlight lock screen images in Windows 10 to a "Windows Spotlight" folder in My Pictures.
<#
.DESCRIPTION
Copies the Windows Spotlight lock screen images in Windows 10 to a "Windows Spotlight" folder in My Pictures.
This script will intelligently sort through the temporary directory and will only copy images
that are 1920x1080. Since the filenames of the images can change, the script will also compare
SHA1 hashes of the existing so we don't copy duplicates.
.NOTES
Version: 1.0.2
@jcefoli
jcefoli / fix_windows_ssh_privkey_permission.ps1
Last active December 1, 2023 05:58
Fix OpenSSH private key permissions on Windows (Solves Windows SSH: Permissions for 'private-key' are too open)
param (
[Parameter(Mandatory=$true)]
[string]$privateKeyFilePath
)
# Remove inheritance from the private key file to prevent inheriting permissions from parent directories
. icacls $privateKeyFilePath /c /t /Inheritance:d
# Grant full control to the current user for keys within the user profile directory
. icacls $privateKeyFilePath /c /t /Grant ${env:UserName}:F