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 September 11, 2025 12:58
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
@stevendborrelli
stevendborrelli / bluesky.md
Last active April 24, 2025 04:52
Bluesky Starter Packs
@eggbean
eggbean / $profile
Last active August 1, 2025 10:43
PowerShell $profile which automatically updates in the background when a new version number appears in this gist.
# Version 1.7.0
$gistUrl = "https://api.github.com/gists/81e7d1be5e7302c281ccc9b04134949e"
$gistFileName = '$profile' # Change this to match the filename in your Gist
$checkInterval = 4 # Check for updates every 4 hours
$updateCheckFile = [System.IO.Path]::Combine($HOME, ".profile_update_check")
$versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)"
$localProfilePath = $Profile.CurrentUserCurrentHost
# Last update check timestamp
@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 October 22, 2025 14:22
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 *latest (GitHub via winget-cli deps)
Microsoft.UI.Xaml *latest (GitHub API)
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 30, 2025 08:06
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") {