Skip to content

Instantly share code, notes, and snippets.

View bender-the-greatest's full-sized avatar

bender-the-greatest

  • CSG International
  • Omaha, NE
View GitHub Profile
@bender-the-greatest
bender-the-greatest / move-me.ps1
Created May 19, 2017 18:20
Script to subtly move the mouse one pixel on an interval in alternating directions.
[CmdletBinding()]
Param()
Add-Type -AssemblyName System.Windows.Forms
Function WaitForKey {
Write-Host 'Press any key to continue...'
[void]$host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
$MAX_MINS = 1440 # Max time in minutes this script can execute
@bender-the-greatest
bender-the-greatest / Verify-TSCertificate.ps1
Last active July 17, 2023 06:50
PowerShell script to validate Terminal Services certificates.
<#
.SYNOPSIS
PowerShell script to validate the served Terminal Services (RDP)
certificate on a Windows Server is valid.
.DESCRIPTION
This script checks the validation of the served Terminal Services certificate
on one or more Windows Servers, and returns an array of PSCustomObjects summarizing the
validation state of the TS certificate of each server.
If the Terminal Services certificate is self-signed or signed by an internal/private CA,
<!--
Mostly this contains custom keybindings, theme, and enables Quake style sliding
-->
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2017-01-05 20:41:54" build="161206">
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
@bender-the-greatest
bender-the-greatest / open-containingfolder.ps1
Created January 5, 2017 05:47
Powershell function which opens the containing folder of a given file
# Powershell function which opens the containing folder of a given file
# in the default program (this will be Windows Explorer 99% of the time).
#
# Note that if -File is actually a folder, it will open that folder's
# parent folder.
#
# Usage:
# Open-ContainingFolder $env:AppData
# Open-ContainingFolder .\somefile.txt
# Open-ContainingFolder C:\Windows\System32\ping.exe
@bender-the-greatest
bender-the-greatest / mousemap.ahk
Created January 5, 2017 04:07
AutoHotKey script for mouse button emulation
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Right clicks
^LButton::RButton
; Middle clicks
^+LButton::MButton
@bender-the-greatest
bender-the-greatest / conemu.ahk
Last active January 5, 2017 05:48
Autohotkey script for ConEmu
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir C:\Projects ; Ensures a consistent starting directory.
^!t::GoSub, FocusOrStartConEmu
;; This will probably not act as intended if you have more than one ConEmu64 process running
FocusOrStartConemu:
if WinExist("ahk_exe ConEmu64.exe")
#Requires -Version 5.1
# This is more of a backup of my profile but if you like it use it I guess.
# Some of the custom functions I have sourced on Github as gists, which are
# commented and documented, unlike these here.
function install-and-import {
Param(
[Parameter(Mandatory=$true)]
[string]$moduleName,
[string]$Scope = 'CurrentUser'
@bender-the-greatest
bender-the-greatest / install-and-import.ps1
Created January 3, 2017 03:55
Installs modules if they are missing prior to import
# Installs modules if they are missing prior to importing
# Does not upgrade modules, only installs them if they are missing
#
# Example usage:
# install-and-import pscx
function install-and-import {
Param(
[Parameter(Mandatory=$true)]
[string]$moduleName
@bender-the-greatest
bender-the-greatest / time-function.ps1
Last active November 4, 2022 11:54
Alternative implementation of Measure-Command, works similarly to Linux `time` command
# Alternative (improved?) implementation of Measure-Command
# Works similarly to the Linux/Unix `time` command
#
# Function which times how long a command takes to completion
# Note that this function outputs to Write-Host so as to
# protect the proper return value. Note that a time will be
# returned even if the command fails.
#
# Unless `-quiet` is specified, command output is sent directly
# to `Write-Host` to allow for the simultaneous return of the
@bender-the-greatest
bender-the-greatest / Convert-MultilineToSingleLine.ps1
Created December 27, 2016 15:40
Powershell function to convert a multiline string to a single line string with line break characters
# Powershell function to convert a multiline string to a single line string with line break characters
#
# Example usage:
# # Replace line breaks with \r\n (Windows-style line endings)
# cat 'nginx.cer' | Convert-MultilineToSingleLine
# # Replace line breaks with \n (Unix/Linux-style line endings)
# cat 'nginx.cer' | Convert-MultilineToSingleLine -n
function Convert-MultilineToSingleLine {
Param(