Skip to content

Instantly share code, notes, and snippets.

View getopt.ps1
# adapted from http://hg.python.org/cpython/file/2.7/Lib/getopt.py
# argv:
# array of arguments
# shortopts:
# string of single-letter options. options that take a parameter
# should be follow by ':'
# longopts:
# array of strings that are long-form options. options that take
# a parameter should end with '='
# returns @(opts hash, remaining_args array, error string)
View Convert-StarDate.ps1
## Convert-StarDate.ps1
#Requires -Version 3
<#
.SYNOPSIS
Calculates the stardate.
.DESCRIPTION
Returns the current stardate with no parameters, or you can enter a specific date as a string or as a DateTime `
object and Get-Stardate will return the stardate for that time.
View Get-LinkTarget.ps1
## Get-LinkTarget.ps1
# Note: Script should be symlinked as follows:
# Get-LinkTarget.ps1 -> Resolve-UNCPath.ps1
# Get-LinkTarget.ps1 -> Resolve-JunctionPath.ps1
# Get-LinkTarget.ps1 -> Resolve-HardlinkPath.ps1
# Get-LinkTarget.ps1 -> Resolve-SymlinkPath.ps1
# Get-LinkTarget.ps1 -> Resolve-ReparsePointPath.ps1
function Global:Get_UNCPath($l_dir)
{
@Trucido
Trucido / promptstuff.ps1
Last active Mar 18, 2019
posh prompt nonsense
View promptstuff.ps1
############################################################################################################################################
## Prompt ##
############################################################################################################################################
Clear-Host
[ScriptBlock]$Prompt = {
$origLastExitCode = $global:LASTEXITCODE
Set-StrictMode -Version 'Latest'
$gitLoaded = $false # skip stupid git module, adds ~1000ms to startup time.
View Get-FileAttributesEx.ps1
## File: Get-FileAttributesEx.ps1
<#
.SYNOPSIS
Lists NTFS file or folder attributes and flags.
.DESCRIPTION
Lists many undocumented or otherwise inaccessible file attributes and flags.
.PARAMETER Path
Path to file(s)/folder(s) to list properties. Wildcards and hidden or system files are supported.
.INPUTS System.Management.Automation.PathInfo, System.String
You can pipe PathInfo objects or strings that contain paths to this cmdlet.
View Get-Clipboard.ps1
<#
Get-Clipboard.ps1 - Gets clipboard content if content type is text.
Note: Conflicts/replaces Pscx\Get-Clipboard which doesn't work in powershell >= 6
#>
function Get-ClipboardText([switch][Alias("S*","L*")]$SplitLF) {
Set-StrictMode -Version 'Latest'
if($SplitLF) {
# Note: Newline CRLF/CR/LF handling should be automatic, but just in case...
$cmd = {
Add-Type -Assembly PresentationCore
View volume.ps1
<#
volume.ps1 - Get/Set IAudioEndpointVolume
Note: Get-Volume/Set-Volume conflicts with Storage\MSFT_Volume
#>
function GetSet-Volume {
Param(
[Parameter(mandatory=$false)] [float] [ValidateRange(0.000,1.000)] $Value,
[Alias("M*","U*")] [switch] $Mute
)
View Get-WSLPaths.ps1
## Get-WSLPaths
<#
.SYNOPSIS
Gets paths and names of WSL distributions installed from Windows Store.
If no parameters supplied, it prints all installed WSL distributions.
.EXAMPLE
PS> Get-WSLPaths debian
PackageFullName : TheDebianProject.DebianGNULinux_1.1.6.0_x64__76v4gfsz19hv4
InstallLocation : C:\Program Files\WindowsApps\TheDebianProject.DebianGNULinux_1.1.6.0_x64__76v4gfsz19hv4
rootfsPSPath : ${env:LOCALAPPDATA}\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs
View Remove-Bloatware.ps1
# Remove-Bloatware.ps1
#Requires -Version 3
#Requires -Modules Appx
#Requires -RunAsAdministrator
$ErrorActionPreference = 'Continue'
$VerbosePreference = 'Continue'
$apps = @(
View pastes.bash.ps1
<#
function tofileio {
[ -f "$1" ] && {
local filename="$1" Uri='https://file.io/';
curl -sL -F file=@"$filename" -H accept: application/json "$Uri" | { jq -r .link 2>/dev/null || cat; }
}
}
#>
function ToFileIO {
if (Test-Path $args[0] -type Leaf) {