Skip to content

Instantly share code, notes, and snippets.

View mikefrobbins's full-sized avatar

Mike F. Robbins mikefrobbins

View GitHub Profile
@dfinke
dfinke / Update-CodePSExePath.ps1
Last active July 15, 2024 06:16
Needs to use `ConvertFrom-Json` the challenge is the settings.json file can have comments `\\` and they fail to parse
function Update-CodePSExePath {
$version=$PSVersionTable.PSVersion.Major
if($version -eq 5) {
$powerShellExePath = (get-command powershell.exe).Source
} else {
$powerShellExePath = (get-command pwsh.exe).Source
}
$settingsFile = "$env:APPDATA\Code\User\settings.json"
@markekraus
markekraus / ConvertKMSEncryptedStrings.ps1
Created February 18, 2018 19:41
PowerShell Functions to convert a string to a base64 representation of the KMS encryoted string and to convert back to an unencrypted string
function ConvertTo-Base64KMSEncryptedString {
[CmdletBinding()]
param (
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true
)]
[String[]]
$String,
@jdhitsolutions
jdhitsolutions / ConvertTo-Markdown.ps1
Created August 15, 2018 14:50
Convert pipeline output to a markdown document
#requires -version 5.0
Function ConvertTo-Markdown {
<#
.Synopsis
Convert pipeline output to a markdown document.
.Description
This command is designed to accept pipelined output and create a markdown document. The pipeline output will formatted as a text block. You can optionally define a title, content to appear before the output and content to appear after the output.
The command does not create a text file. You need to pipe results from this command to a cmdlet like Out-File or Set-Content. See examples.
.Parameter Title
@IISResetMe
IISResetMe / ConvertTo-Object.ps1
Last active July 25, 2023 23:12
Quick and dirty regex-based text-to-object parsing using named expressions groups and $Matches
function ConvertTo-Object {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[AllowEmptyString()]
[string[]]$InputString,
[Parameter(Mandatory=$true,ValueFromRemainingArguments=$true)]
[string[]]$Pattern
)
@SteveL-MSFT
SteveL-MSFT / profile.ps1
Last active July 2, 2025 17:52
PowerShell Prompt
#Requires -Version 7
# Version 1.2.13
# check if newer version
$gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e"
$latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version')
$versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)"
if ([System.IO.File]::Exists($latestVersionFile)) {
@pcgeek86
pcgeek86 / cheatsheet.ps1
Last active October 23, 2025 18:34
PowerShell Cheat Sheet / Quick Reference
Get-Command # Retrieves a list of all the commands available to PowerShell
# (native binaries in $env:PATH + cmdlets / functions from PowerShell modules)
Get-Command -Module Microsoft* # Retrieves a list of all the PowerShell commands exported from modules named Microsoft*
Get-Command -Name *item # Retrieves a list of all commands (native binaries + PowerShell commands) ending in "item"
Get-Help # Get all help topics
Get-Help -Name about_Variables # Get help for a specific about_* topic (aka. man page)
Get-Help -Name Get-Command # Get help for a specific PowerShell function
Get-Help -Name Get-Command -Parameter Module # Get help for a specific parameter on a specific command
@Francisco-Gamino
Francisco-Gamino / Az.Functions.md
Last active September 23, 2024 13:21
Az.Functions - Managing Azure Functions via PowerShell.
# Managing Azure Functions via PowerShell Cmdlets
# Prerequisites:
# - PowerShell Core 6 or greater --> https://github.com/PowerShell/PowerShell/releases
# - Core Tools --> https://github.com/Azure/azure-functions-core-tools#installing
# - Az.Functions preview module --> https://www.powershellgallery.com/packages/Az.Functions/0.0.2-preview

# Install Azure Functions PowerShell core module
Install-Module -Name Az.Functions -AllowPrerelease
@awakecoding
awakecoding / PascalSnakeCase.ps1
Created January 22, 2020 01:02
PowerShell ConvertTo-PascalCase, ConvertTo-SnakeCase
function ConvertTo-PascalCase
{
[OutputType('System.String')]
param(
[Parameter(Position=0)]
[string] $Value
)
# https://devblogs.microsoft.com/oldnewthing/20190909-00/?p=102844
return [regex]::replace($Value.ToLower(), '(^|_)(.)', { $args[0].Groups[2].Value.ToUpper()})
@JustinGrote
JustinGrote / AutoMock.ps1
Last active November 2, 2021 21:16
AutoMock: Record Powershell Command Output to Replay in Pester Tests Offline
#requires -module Indented.StubCommand
function Enable-AutoMockRecord ([Switch]$Append) {
$env:AUTOMOCK_RECORD = $true
if ($Append) {$env:AUTOMOCK_APPEND = $true}
}
function Disable-AutoMockRecord {
Remove-Item env:AUTOMOCK_RECORD -ErrorAction SilentlyContinue
Remove-Item env:AUTOMOCK_APPEND -ErrorAction SilentlyContinue
}
@timothywarner
timothywarner / az900sg.md
Created October 15, 2020 12:31
AZ-900 Microsoft Azure Fundamentals Study Blueprint