Skip to content

Instantly share code, notes, and snippets.

View JeremyTBradshaw's full-sized avatar
🤠
Yeehaw

Jeremy JeremyTBradshaw

🤠
Yeehaw
View GitHub Profile
@JeremyTBradshaw
JeremyTBradshaw / New-FakeThumbprint.ps1
Last active December 3, 2020 17:34
Quick fake certificate thumbprints (and Guid's)
# For documentation purposes, sometimes I need fake thumbprints (and Guid's).
function New-FakeThumbprint ([ValidateRange(1, 10)][int]$Count = 1) {
1..$Count | ForEach-Object {
(
1..40 | Foreach-Object {
Get-Random @('A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
}
) -join ''
@JeremyTBradshaw
JeremyTBradshaw / ConvertFrom-SecureStringToPlainText.ps1
Last active January 30, 2023 09:30
For PowerShell 5.1 and older, convert secure strings back to plain text
function ConvertFrom-SecureStringToPlainText ([System.Security.SecureString]$SecureString) {
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
)
}
New-Alias -Name s2p -Value ConvertFrom-SecureStringToPlainText
#Requires -Version 5.1
using namespace System.Management.Automation.Host
switch (
$host.UI.PromptForChoice(
"Caption (e.g. 'XYZ has come up!')",
"Message (e.g. 'How would you like to proceed?",
[ChoiceDescription[]]@(
@JeremyTBradshaw
JeremyTBradshaw / GuidToImmutableIdAndBack.ps1
Last active July 27, 2022 14:13
Convert between Guid and ImmutableId (for Azure AD / Office 365 customers)
#Requires -Version 3
function ConvertFrom-GuidToImmutableId ([Guid]$Guid){
[System.Convert]::ToBase64String([Guid]::Parse($Guid).ToByteArray())
}
New-Alias -Name g2i -Value ConvertFrom-GuidToImmutableId
function ConvertFrom-ImmutableIdToGuid ([string]$ImmutableId) {
@JeremyTBradshaw
JeremyTBradshaw / New-Password.ps1
Last active April 13, 2023 01:02
PowerShell Password Generator
<#
.Synopsis
Generate one or more random passwords, from 7 to 64 characters in length.
.Description
Passwords are generated using an equal distribution of upper and lower case letters, numbers, space, and special
characters found on the number row.
.Parameter Length
Specifies the length of the generated password(s).