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 / 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,
@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 / Configure-SecureWinRM.ps1
Created July 20, 2017 15:55
Configure WinRM to listen over SSL (port 5986) and use the web certificate generated by a certificate templated called 'WinRM'. Highly recommend reading Synopsis, Description, and Examples.
<#
.SYNOPSIS
Configures a secure WinRM listener over HTTPS to enable
SSL-based WinRM communications. This script has not been
tested on Windows Server 2003R2 or earier, and may not
work on these OSes for a variety of reasons.
If Windows Remote Management is disabled (e.g. service
stopped, GPO Policy, etc.), this script will likely fail.
.DESCRIPTION
@bender-the-greatest
bender-the-greatest / atom-friendly-phils-zsh-prompt.zsh
Created July 24, 2017 02:53
Phil!'s ZSH Prompt - Atom-Friendly. Original version breaks when Atom is installed due to dependency on Atom Package Manager, which overrides the `apm` command.
function precmd {
local TERMWIDTH
(( TERMWIDTH = ${COLUMNS} - 1 ))
###
# Truncate the path if it's too long.
PR_FILLBAR=""
@bender-the-greatest
bender-the-greatest / Trust-AllCerts.ps1
Last active September 17, 2020 13:34
Code snippet to ignore SSL errors when making HTTPS requests in Powershell. Originally sourced from https://www.reddit.com/r/PowerShell/comments/6emjly/ignoring_ssltls_errors_using_invokewebrequest/
# DISCLAIMER - This is provided as a method to interface with HTTPS endpoints configured
# with an invalid certificate as is common during the development process. This is not
# intended or recommended to be used in a production scenario for obvious security reasons.
#
# Also, I did not write the C# code. Props to kd0shk and the Powershell subreddit for the C# snippet.
# Both of these approaches won't work in PowerShell core and is not required as built-in
# request cmdlets now have the -SkipCertificateCheck parameter
# (e.g. Invoke-WebRequest -SkipCertificateCheck https://server.withbadcert.domain.tld)
@bender-the-greatest
bender-the-greatest / Random-CatFact.ps1
Created April 5, 2019 16:31
Random-CatFact.ps1 - Reads a random cat fact out loud. Fun to run this with Invoke-Command on your co-workers' or boss' workstations when they aren't busy.
Add-Type -AssemblyName System.Speech
$SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$SpeechSynth.SelectVoice( 'Microsoft Zira Desktop' )
$CatFact = Invoke-RestMethod -UseBasicParsing https://catfact.ninja/fact
$SpeechSynth.speak( "Did you know? $($CatFact.fact)" )
@bender-the-greatest
bender-the-greatest / cloudSettings
Last active August 21, 2020 16:12
My preferred VSCode settings and extensions
{"lastUpload":"2020-08-21T16:12:30.636Z","extensionVersion":"v3.4.3"}
@bender-the-greatest
bender-the-greatest / Get-ChocolateyOutdatedPackages.ps1
Created February 7, 2020 03:15
Get outdated Chocolatey packages on the local system as a usable PowerShell object
Function Get-ChocolateyOutdatedPackages {
<#
.SYNOPSIS
Gets outdated Chocolatey packages on the local system
.DESCRIPTION
Returns an array of objects with the following properties:
- PackageName: [string] Name of the Chocolatey package.
- CurrentVersion: [string] Current version of the Chocolatey package.
@bender-the-greatest
bender-the-greatest / Get-CanWriteDirectory.ps1
Last active August 18, 2025 08:43
Function to check whether the current user has write permissions to a directory or not
#Requires -Version 6.2
function Get-CanWriteDirectory {
[CmdletBinding()]
Param(
[Parameter(Mandatory, Position=0)]
[ValidateScript(
{ Test-Path -PathType Container $_ },
# Remove this property to make compatible with 5.1, 6.0, and 6.1
ErrorMessage = "Could not find the path or it is not a directory: {0}"
@bender-the-greatest
bender-the-greatest / Set-WineEnv.ps1
Last active October 8, 2020 07:13
Configure a new wine prefix. A bit convoluted since I wanted this to set up a shared Wine directory, but Wine doesn't support multiuser scenarios. Run Set-WineEnv, the other two functions are helpers used in that function.
function Get-CanWriteDirectory {
[CmdletBinding()]
Param(
[Parameter(Mandatory, Position=0)]
[ValidateScript(
{ Test-Path -PathType Container $_ },
ErrorMessage = "Could not find the path or it is not a directory: {0}"
)]
[string]$Path
)