Skip to content

Instantly share code, notes, and snippets.

View SamErde's full-sized avatar
:octocat:
Writing PowerShell

Sam Erde SamErde

:octocat:
Writing PowerShell
View GitHub Profile
@JustinGrote
JustinGrote / ProfileBenchmark.ps1
Last active March 20, 2025 12:47
Benchmark your profile using Profiler
#region ProfileBenchmark
if ($ENV:PWSH_PROFILE_BENCHMARK -and -not $ENV:PWSH_PROFILE_BENCHMARK_RUN) {
Write-Host -Fore Magenta '👷‍♂️ BENCHMARKING PROFILE SETUP'
Invoke-WebRequest bit.ly/modulefast | Invoke-Expression
Install-ModuleFast profiler
# This will ensure we don't end up in a setup loop
Write-Host -Fore Magenta '📈 BENCHMARKING PROFILE'
$profilePath = $MyInvocation.MyCommand.Source
$profileTrace = Trace-Script -ExportPath TEMP:/pwsh-profile -ScriptBlock {
@jakehildreth
jakehildreth / Out-HostColored.ps1
Created December 13, 2024 10:57 — forked from mklement0/Out-HostColored.ps1
PowerShell function that colors portions of the default host output that match given patterns.
<#
Prerequisites: PowerShell version 2 or above.
License: MIT
Author: Michael Klement <[email protected]>
DOWNLOAD, from PowerShell version 3 or above:
irm https://gist.github.com/mklement0/243ea8297e7db0e1c03a67ce4b1e765d/raw/Out-HostColored.ps1 | iex
@okineadev
okineadev / commit-message-guidelines.md
Last active April 19, 2025 23:05
🤖 Copilot commit messages instructions for VS Code

Paste it to settings.json:

"github.copilot.chat.commitMessageGeneration.instructions": [
  {
    "text": "Follow the Conventional Commits format strictly for commit messages. Use the structure below:\n\n```\n<type>[optional scope]: <gitmoji> <description>\n\n[optional body]\n```\n\nGuidelines:\n\n1. **Type and Scope**: Choose an appropriate type (e.g., `feat`, `fix`) and optional scope to describe the affected module or feature.\n\n2. **Gitmoji**: Include a relevant `gitmoji` that best represents the nature of the change.\n\n3. **Description**: Write a concise, informative description in the header; use backticks if referencing code or specific terms.\n\n4. **Body**: For additional details, use a well-structured body section:\n   - Use bullet points (`*`) for clarity.\n   - Clearly describe the motivation, context, or technical details behind the change, if applicable.\n\nCommit messages should be clear, informative, and professional, aiding readability and project tracking."
  }
]
@stevendborrelli
stevendborrelli / bluesky.md
Last active April 19, 2025 04:50
Bluesky Starter Packs
@JustinGrote
JustinGrote / Get-InstalledModuleFast.ps1
Last active October 16, 2024 19:09
Get info about locally installed PowerShell modules
function Get-InstalledModuleFast {
param(
#Modules to filter for. Wildcards are supported.
[string]$Name,
#Path(s) to search for modules. Defaults to your PSModulePath paths
[string[]]$ModulePath = ($env:PSModulePath -split [System.IO.Path]::PathSeparator),
#Return all installed modules and not just the latest versions
[switch]$All
)

Example SSH Server Initialization

The SSH server configuration requires GSSAPIAuthentication yes.

Ref: https://snozzberries.github.io/2023/08/29/powershell-ssh.html

$r=[System.Net.WebRequest]::Create("https://github.com/PowerShell/PowerShell/releases/latest")
$r.AllowAutoRedirect=$false
$r.Method="Head"
@bentman
bentman / Add-DevToMyWinServer.ps1
Last active April 2, 2025 10:32
Install Dev Tools on Win Server 2022
<#
.SYNOPSIS
Script to install Dev Tools on Windows Server (tested on 2022)
.DESCRIPTION
Installs the following from multiple resources:
Microsoft.VCLibs v14.00 (github)
Microsoft.UI v2.8.6 (github)
winget-cli (dynamic version retrieval from api.github.com)
Microsoft.WindowsTerminal (dynamic version retrieval from api.github.com)
Microsoft pwsh.exe vCurrent (winget)
@awakecoding
awakecoding / Get-AadJoinInformation.ps1
Created August 8, 2023 14:21
Get Azure AD (Entra ID) Join Information without dsregcmd
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
public enum DSREG_JOIN_TYPE {
DSREG_UNKNOWN_JOIN = 0,
DSREG_DEVICE_JOIN = 1,
DSREG_WORKPLACE_JOIN = 2
}
@mdgrs-mei
mdgrs-mei / TerminalSpinner.ps1
Created June 15, 2023 14:43
Show spinner on the Windows Terminal tabs for every command.
$global:originalPSConsoleHostReadLine = $function:global:PSConsoleHostReadLine
$global:originalPrompt = $function:global:Prompt
$function:global:PSConsoleHostReadLine = {
$startProgressIndicator = "`e]9;4;3;50`e\"
$command = $originalPSConsoleHostReadLine.Invoke()
$startProgressIndicator | Write-Host -NoNewLine
$command
}
@jedieaston
jedieaston / Install-WinGet.ps1
Last active July 25, 2023 22:08
Install WinGet (.ps1)! (on x64 systems)
$ErrorActionPreference = "Stop"
$apiLatestUrl = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
$tempFolder = $env:TEMP
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$WebClient = New-Object System.Net.WebClient
function Update-EnvironmentVariables {
foreach($level in "Machine","User") {