Skip to content

Instantly share code, notes, and snippets.

@joegasper
joegasper / ConvertFrom-DN
Last active September 28, 2023 08:17
Convert between DistinguishedName and CanonicalName
#Updated ConvertFrom-DN to support container objects
function ConvertFrom-DN {
[cmdletbinding()]
param(
[Parameter(Mandatory, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
[ValidateNotNullOrEmpty()]
[string[]]$DistinguishedName
)
process {
@joegasper
joegasper / GPU-P-Partitioning.ps1
Last active September 19, 2023 15:57
GPU-P Partitioning Script
# Name of Hyper-V VM
$vm = "MyVMName"
# Total VRAM of physical GPU (GPU-P)
$TotalGPUpVram = 6Gb
# Percent of physical GPU resources to allocate to virtual GPU in the VM
[int]$GPUpAllocationPercent = 25
# Calculate the high memory mapped IO value based on total GPU-P VRAM
@joegasper
joegasper / ConvertTo-SRT.ps1
Last active July 10, 2023 01:53
Convert VTT files to SRT format
<#
.SYNOPSIS
Fast conversion of Microsoft Stream VTT subtitle file to SRT format.
.DESCRIPTION
Uses select-string instead of get-content to improve speed 2 magnitudes.
.PARAMETER Path
Specifies the path to the VTT text file (mandatory).
.PARAMETER OutFile
Specifies the path to the output SRT text file (defaults to input file with .srt).
.EXAMPLE
@joegasper
joegasper / Set-DnsClient2CloudFlareDnsService
Created April 2, 2018 01:03
Set Windows client to use CloudFlare DNS Service 1.1.1.1
#See: https://1.1.1.1/ and https://www.cnet.com/news/cloudfare-new-1111-dns-privacy-tool-would-speed-your-internet-too/
#Run in elevated PowerShell command shell
#Store current DNS servers
Get-NetAdapter -Physical | Where-Object {$_.Status -eq 'Up'} | Get-DnsClientServerAddress | Select ServerAddresses -expand ServerAddresses | Set-Content -Path $env:USERPROFILE\OriginalDNSservers.txt
$Display current DNS servers
Get-NetAdapter -Physical | Where-Object {$_.Status -eq 'Up'} | Get-DnsClientServerAddress
#Specifiy CloudFlare 1.1.1.1 service IP addresses (IPv4/IPv6)
$DNSservers = ('1.1.1.1','1.0.0.1','2606:4700:4700::1111','2606:4700:4700::1001')
#Set client DNS servers to CloudFlare DNS servers
Get-NetAdapter -Physical | Where-Object {$_.Status -eq 'Up'} | Set-DnsClientServerAddress -ServerAddresses $DNSservers
@joegasper
joegasper / Get-PHPVersion.ps1
Created February 4, 2023 18:04
Given a path, determine installed version of PHP
function Get-PHPVersion {
<#
.SYNOPSIS
Given a path, determine installed version of PHP.
.DESCRIPTION
The provided path will be searched for php.exe files and return the version of found PHP executables.
.PARAMETER Path
Path to search
.EXAMPLE
Get-PHPVersions -Path E:\PHP
@joegasper
joegasper / Get-TeamsReactionImages.ps1
Created February 2, 2023 16:07
Download reaction images for Microsoft Teams plug-in for Stream Deck
### Download reaction images for Microsoft Teams plug-in for Stream Deck
$csv = @"
"URL","FileName"
"https://github.com/microsoft/fluentui-emoji/blob/main/assets/Raised%20hand/Default/3D/raised_hand_3d_default.png","RaiseHand.png"
"https://github.com/microsoft/fluentui-emoji/blob/main/assets/Thumbs%20up/Default/3D/thumbs_up_3d_default.png","Like.png"
"https://github.com/microsoft/fluentui-emoji/blob/main/assets/Red%20heart/3D/red_heart_3d.png","Love.png"
"https://github.com/microsoft/fluentui-emoji/blob/main/assets/Clapping%20hands/Default/3D/clapping_hands_3d_default.png","Applause.png"
"https://github.com/microsoft/fluentui-emoji/blob/main/assets/Face%20with%20open%20mouth/3D/face_with_open_mouth_3d.png","Wow.png"
"https://github.com/microsoft/fluentui-emoji/blob/main/assets/Grinning%20squinting%20face/3D/grinning_squinting_face_3d.png","Laugh.png"
"@
@joegasper
joegasper / wp-cli-install-on-windows.md
Created January 21, 2023 05:59
WordPress WP-CLI Installation on Windows

WordPress WP-CLI Installation on Windows

Prerequisites: Chocolatey, PHP, Composer

Use an elevated PowerShell console

Install chocolatey

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Convert-ADName.ps1
# Written by Bill Stewart (bstewart@iname.com)
# PowerShell wrapper script for the NameTranslate COM object.
#requires -version 2
<#
.SYNOPSIS
Translates Active Directory names between various formats.
@joegasper
joegasper / windows_hardening.cmd
Created November 27, 2022 03:17 — forked from mackwage/windows_hardening.cmd
Script to perform some hardening of Windows OS
:: Windows 10 Hardening Script
:: This is based mostly on my own personal research and testing. My objective is to secure/harden Windows 10 as much as possible while not impacting usability at all. (Think being able to run on this computer's of family members so secure them but not increase the chances of them having to call you to troubleshoot something related to it later on). References for virtually all settings can be found at the bottom. Just before the references section, you will always find several security settings commented out as they could lead to compatibility issues in common consumer setups but they're worth considering.
:: Obligatory 'views are my own'. :)
:: Thank you @jaredhaight for the Win Firewall config recommendations!
:: Thank you @ricardojba for the DLL Safe Order Search reg key!
:: Thank you @jessicaknotts for the help on testing Exploit Guard configs and checking privacy settings!
:: Best script I've found for Debloating Windows 10: https://github.com/Sycnex/Windows10Debloater
:
@joegasper
joegasper / New-DicePassPhrase7.ps1
Created September 13, 2021 21:51
Generate a password/passphrase based on a dice password list - only PowerShell Core/7 - added support for parallel foreach
<#
.SYNOPSIS
Returns a passphrase
.DESCRIPTION
Returns a passphrase based on a dice password list.
.EXAMPLE
New-DicePassPhrase
miles welt eta pall 41st