A collection of PowerShell tools you can add to your profile.
docs 🏗️
- Clone this repository to
$env:OneDrive/Documents/Snippets
- In an Administrator elevated editor, edit
$PROFILE.AllUsersAllHosts
. - Add
$env:Snippets="$env:OneDrive/Documents/PowerShell/Snippets"
to the end and save it.
- Clone this repository to
/opt/microsoft/powershell/7/Snippets
- In an Administrator elevated editor, edit
$PROFILE.AllUsersAllHosts
. - Add
$env:Snippets="/opt/microsoft/powershell/7/Snippets"
to the end and save it.
OR
Execute this script...
curl 'https://raw.githubusercontent.com/PS-Services/Snippets/master/linux-setup.sh' -v | /bin/bash
Win | *nix | Script | Description |
---|---|---|---|
✅ | ✅ | bing.ps1 | Search Bing from Powershell. |
✅ | ✅ | clean‑folder.ps1 | Remove all bin and obj folders in current path. |
✅ | ✅ | github.ps1 | Set $env:GITHUB first to the root of your github repositories. Use hub or hub <repository> to go to those folders. |
✅ | ✅ | oh‑my‑posh.ps1 | Initializes Oh-My-Posh for the current PowerShell |
✅ | ✅ | _repos.ps1 | A unified repository query system. |
✅ | chocolatey.ps1 | Setup Chocolatey profile in PowerShell. | |
✅ | devmode.ps1 | Startup VS 2022 Dev Mode Tools. |
Place calls to these files in your $PROFILE
All scripts work in both PowerShell Core and Windows PowerShell 5.1!
$env:Snippets="$env:OneDrive\Documents\PowerShell\Snippets"
if ($env:VerboseStartup -eq 'true') {
[switch]$Verbose = $true
}
else {
[switch]$Verbose = $false
}
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
try {
Import-Module Microsoft.PowerShell.Utility
if (Test-Path $env:Snippets) {
Push-Location
Set-Location $env:Snippets
$snippets = Get-ChildItem *.ps1
Pop-Location
$snippets.FullName | ForEach-Object -Process {
$snippet = $_
. $snippet -Verbose:$Verbose
}
}
else {
Write-Verbose "No directory found at [$env:Snippets]" -Verbose:$Verbose~
}
Write-Verbose 'PowerShell Ready.' -Verbose:$Verbose
}
catch {
Write-Host $Error
}
finally {
Write-Verbose "Leaving $Profile" -Verbose:$Verbose
}
# $env:VerboseStartup = 'true'
$profileScript = Split-Path $PROFILE -Leaf
if((-not $env:Snippets) -or (-not (Test-Path $env:Snippets))) {
$env:Snippets = "$env:HOME/.config/powershell"
}
if ($env:VerboseStartup -eq 'true') {
[switch]$MasterVerbose = $true
}
else {
[switch]$MasterVerbose = $false
}
try {
Push-Location -Verbose:$MasterVerbose
Import-Module Microsoft.PowerShell.Utility #-Verbose:$MasterVerbose
$env:Snippets = Join-Path $env:Snippets -Child Snippets -Verbose:$MasterVerbose
if (-not (Test-Path $env:Snippets -Verbose:$MasterVerbose)) {
git clone "https://github.com/sharpninja/Snippets.git"
} else {
Write-Verbose "[$profileScript] Found $env:Snippets" -Verbose:$MasterVerbose
}
if (Test-Path $env:Snippets -Verbose:$MasterVerbose) {
Push-Location -Verbose:$MasterVerbose
Set-Location $env:Snippets -Verbose:$MasterVerbose
$snippets = Get-ChildItem *.ps1 -Verbose:$MasterVerbose -Exclude _common.ps1
Pop-Location -Verbose:$MasterVerbose
$resultList = @()
$snippets.FullName | ForEach-Object -Verbose:$MasterVerbose -Process {
try {
$snippet = $_
$snippetName = Split-Path $snippet -Leaf
Write-Verbose "[$profileScript]->[$snippetName] Calling with: -Verbose:`$$MasterVerbose" -Verbose:$MasterVerbose
$result = $null
$result = . $snippet -Verbose:$MasterVerbose
}
catch {
Write-Error "[$profileScript]->[$snippetName] Error: $_"
}
finally {
$report = "[$snippetName]->[ $result ]"
$resultList += $report;
}
}
if ($resultList.Length -gt 0) {
"[$profileScript] Snippet Results`n---`n$([System.String]::Join("`n", $resultList))`n---`n"
}
else {
"[$profileScript] No snippets where executed."
}
}
else {
Write-Verbose "[$profileScript] No directory found at [$env:Snippets]" -Verbose:$MasterVerbose
}
}
catch {
Write-Error "[$profileScript] $_"
}
finally {
Pop-Location
Write-Verbose "Leaving $Profile" -Verbose:$MasterVerbose
}
Get-Alias -Verbose:$MasterVerbose `
| Where-Object -Property Description -imatch 'snippet' -Verbose:$MasterVerbose `
| Format-Table Name, Description -AutoSize -Verbose:$MasterVerbose
Write-Verbose 'PowerShell Ready.' -Verbose:$MasterVerbose
dn
dotnetdt
dotnet toolng
nugetnp
NPMpp
pippps
pip-search
repos
Search all OS reposwq
wingetscp
scoopch
chocolatey
EXAMPLE
repos oh-my-pos
Repo Command
---- -------
scoop install [email protected]
sudo choco install oh-my-posh --version 18.5.0 -y
winget install XP8K0HKJFRXGCK -s msstore # oh-my-posh
repos
Search all OS reposap
aptzy
zyppersn
snapbr
homebrew