Skip to content

Instantly share code, notes, and snippets.

View rmbolger's full-sized avatar

Ryan Bolger rmbolger

View GitHub Profile
@rmbolger
rmbolger / d8-viz.ps1
Last active December 8, 2021 19:46
A simple visualization of Advent of Code 2021 - Day 8 part 2
<#
.SYNOPSIS
A simple visualization of Advent of Code 2021 - Day 8 part 2
.EXAMPLE
Get-Content .\d8.txt | .\d8-viz.ps1
Run visualization from input file
.EXAMPLE
@rmbolger
rmbolger / Find-LetsEncryptChainCerts.ps1
Last active December 7, 2023 16:30
Find copies of Let's Encrypt related chain/root certificates on Windows
#Requires -Version 2.0
<#
.SYNOPSIS
Find copies of Let's Encrypt related chain/root certificates.
.DESCRIPTION
This script searches all certificate stores both for the Local Computer and all active Local User accounts with an HKEY_USERS registry hive loaded.
It does not require running as administrator, but will throw warnings for registry locations it can't read. So it is suggested to run as administrator.
@rmbolger
rmbolger / Find-ExpiredR3.ps1
Last active October 1, 2021 19:15
Find Expired R3 Intermediate Certificates on Windows
#Requires -Version 5.1
#Requires -RunAsAdministrator
[CmdletBinding()]
param(
[switch]$Remediate,
[switch]$Quiet
)
$InformationPreference = 'Continue'
@rmbolger
rmbolger / SortingClasses.ps1
Last active September 24, 2020 17:10
Sorting classes for FQDNs and CIDR strings
# I like to add these to my PowerShell profile so I can more easily sort FQDNs and CIDR network strings.
# The FQDN sorter will sort based on the labels in reverse order. So .com's will sort near each other,
# everything within the same domain will sort near each other, etc.
#
# 'a.example.org','a.example.com','example.org','example.com' | sort {[Fqdn]$_}
class Fqdn : IComparable
{
[string]$Fqdn
@rmbolger
rmbolger / Test-IPInSubnet.ps1
Created July 23, 2020 05:45
Test-IPInSubnet.ps1
function Test-IPInSubnet {
[CmdletBinding()]
param(
[Parameter(Mandatory,Position=0)]
[string]$IP,
[Parameter(Mandatory,Position=1)]
[string[]]$Subnet
)
$IPval = ([ipaddress]$IP).Address
@rmbolger
rmbolger / ParseNetlogonDns.ps1
Created June 7, 2019 13:24
Parses the netlogon.dns file on an Active Directory domain controller to display a nicely formatted and sorted list of required DNS records for that DC
gc "$($env:SYSTEMROOT)\System32\config\netlogon.dns" | %{ $p = $_.Split(' '); $d = ($p[4..($p.Count-1)] -join ' '); [pscustomobject]@{name=$p[0].Trim('.').Split('.');ttl=$p[1];type=$p[3];data=$d} } | sort @{E={$a=@()+$_.name;[Array]::Reverse($a);$a}},type,data | select @{L='rec';E={$_.name[0]}},@{L='zone';E={$_.name[1..($_.name.Count-1)] -join '.'}},ttl,type,data
@rmbolger
rmbolger / keybase.md
Created January 23, 2019 04:31
KeyBase proof

Keybase proof

I hereby claim:

  • I am rmbolger on github.
  • I am rmbolger (https://keybase.io/rmbolger) on keybase.
  • I have a public key ASBwymVX2hfBKfUWYAKBxNK-6syGE2xymydggktaYMuogQo

To claim this, I am signing this object:

@rmbolger
rmbolger / Get-UidFromSid.ps1
Last active April 12, 2024 00:59
Functions for converting a SID to a UID for use with RFC2307 attributes in Active Directory
function Get-UidFromSid
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[System.Security.Principal.SecurityIdentifier]$sid
)
Process {
# convert sid to byte array
@rmbolger
rmbolger / Convert-PfxToPem.ps1
Last active January 10, 2022 17:56
Convert-PfxToPem.ps1
# Adapted from Vadims Podāns' amazing work here.
# https://www.sysadmins.lv/blog-en/how-to-convert-pkcs12pfx-to-pem-format.aspx
#
# Also, if you need a more complete PKI PowerShell module, he has authored one here:
# https://github.com/Crypt32/PSPKI
#
# This version of the function includes a few fixes from the module's version of the
# function and changes up the output options so you get separate .crt/.key files by
# default named the same as the pfx file (or thumbprint if directly referencing a cert).
# -IncludeChain adds an additional -chain.pem. Relative paths are now
@rmbolger
rmbolger / Disable-SSLCertChecking.ps1
Created March 16, 2017 00:05
Disable Cert Validation for Powershell
# http://stackoverflow.com/a/38729034/75772
# https://d-fens.ch/2013/12/20/nobrainer-ssl-connection-error-when-using-powershell/
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback=@"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback