Skip to content

Instantly share code, notes, and snippets.

View jcefoli's full-sized avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / gist:f8002ffce3b0c1296d959b8d4ad0a471
Created July 25, 2019 06:29
Re-Enable IPv6 (My Company blocks it via reg key and this removes that key easily)
Get-Item -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters | Remove-ItemProperty -Name "DisabledComponents"
@jcefoli
jcefoli / imagick3.4.4-PHP7.2-forge.sh
Last active June 4, 2019 06:37
Install Imagick 3.4.4 on PHP 7.2 server (Laravel Forge)
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.4.tgz
tar xvzf imagick-3.4.4.tgz
@jcefoli
jcefoli / az-redis-cli.ps1
Last active January 29, 2019 20:22
Connect To Azure Redis Instance Using TLS and stunnel
<#
.SYNOPSIS
Connect to Azure Redis CLI over TLS instances using Stunnel.
.Description
This script helps you manage connecting to multiple redis instances in Azure by modifying the stunnel config automagically
ASSUMPTIONS AND WARNINGS:
==============================
- Must run in an elevated PowerShell prompt
@jcefoli
jcefoli / elevate.ps1
Created January 28, 2019 13:29
Self-elevating Powershell Script (Detects if you're not Admin and relaunches with privileges)
# Based on: https://blogs.msdn.microsoft.com/virtual_pc_guy/2010/09/23/a-self-elevating-powershell-script/
# Get the ID and security principal of the current user account
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
# Get the security principal for the Administrator role
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
# Check to see if we are currently running "as Administrator"
@jcefoli
jcefoli / split_file.ps1
Last active October 24, 2019 17:40
Split File By Number of Lines PowerShell One-Liner)
$i=0; Get-Content input.txt -ReadCount 25 | %{$i++; $_ | Out-File out_$i.txt}
@jcefoli
jcefoli / create_clustered_private_msmq_queues.ps1
Created October 27, 2018 09:02
Create Clustered Private MSMQ Queues And Grant Windows User Permissions
<#
.SYNOPSIS
Create Clustered Private MSMQ Queues And Grant Windows User Permissions
.NOTES
Version: 1.0
Author: jcefoli
Creation Date: 10/27/2018
Run this on the active MSMQ cluster node. It may fail if run on the inactive node, as it will not be able to access the queues
@jcefoli
jcefoli / keepalive.ps1
Last active October 28, 2024 18:19
Powershell Computer Keepalive (Anti-Idle)
<#
This script will prevent GPOs from enabling the screensaver, shutting off your screen, or force-locking your workstation
It works by sending an F15 keystroke every minute (only if there have been no keystrokes or mouse movement for 30 seconds)
Be green - if you want to use this, power off your monitor(s)!
#>
Add-Type @'
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
@jcefoli
jcefoli / msmq_message_copier.ps1
Last active February 22, 2021 04:29
Get MSMQ Queue Size and Copy All Messages to Another Queue
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | Out-Null
#Define Queue Connection Info Here (In this case, we're passing the IP to a clustered MSMQ instance)
$fromQueueConnString = "FormatName:Direct=TCP:172.1.1.1\private$\queue_to_copy_messages_from"
$toQueueConnString = "FormatName:Direct=TCP:172.1.1.1\private$\queue_to_copy_messages_to" # Make sure this queue exists - I don't create it and it might fail
# Get Queue Size - https://stackoverflow.com/a/2291087
$qsource = @"
public class QueueSizer
{
@jcefoli
jcefoli / git_change_permissions.sh
Created April 9, 2018 15:59
File Permissions in Git (Useful on Windows)
# Show permissions
git ls-tree HEAD
# Make Executable
git update-index --chmod=+x some_file.sh
040e67fa7ece009d4becef9f4d74ddb8d0986b60c8acf9a72f0647aae4c39fd407c5207f2c78b3c8bd9612dd13f7d6bc4b39b5bb91a4fdbb5fa6ddb8c120f03f22;webandtech