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
@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 January 15, 2025 13:53
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 January 2, 2025 13:35
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") {
@eizedev
eizedev / Get-CommandSourceCode.ps1
Last active December 9, 2024 19:27
Get SourceCode of any powershell cmdlet/function by using the command metadata
function Get-CommandSourceCode
{
<#
.SYNOPSIS
Get SourceCode of an powershell cmdlet
.DESCRIPTION
Get SourceCode of an powershell cmdlet
.PARAMETER Command
Must be a valid powershell cmdlet/function
.EXAMPLE
@eizedev
eizedev / Get-LastPowershellErrorType.ps1
Created January 13, 2021 10:12
Get error type of last powershell error
$Error[0].Exception.GetType().FullName