Skip to content

Instantly share code, notes, and snippets.

@rkeithhill
rkeithhill / build.ps1
Last active April 2, 2020 15:33
PSake build script for publishing PowerShell modules
# This is a PSake script that supports the following tasks:
# clean, build, test and publish. The default task is build.
#
# The publish task uses the Publish-Module command to publish
# to either the PowerShell Gallery (the default) or you can change
# the $Repository property to the name of an alternate repository.
#
# The test task invokes Pester to run any Pester tests in your
# workspace folder. Name your test scripts <TestName>.Tests.ps1
# and Pester will find and run the tests contained in the files.
@rkeithhill
rkeithhill / powershell.json
Last active February 23, 2024 23:18
PowerShell snippets file for Visual Studio Code - place in your ~\AppData\Roaming\Code\User\Snippets directory
{
"Condition statement": {
"prefix": "cond",
"body": [
"$1 { $0; break }"
],
"description": "Switch condition statement"
},
"Condition single quoted string statement": {
"prefix": "condsqstr",
@rkeithhill
rkeithhill / PSReadLine_config.ps1
Last active December 10, 2023 03:03
Config file for PSReadLine
# Other hosts (ISE, ConEmu) don't always work as well with PSReadLine.
# Also, if PS is run with -Command, PSRL loading is suppressed.
$psrlMod = Get-Module PSReadLine
if (($null -eq $psrlMod) -or ($host.Name -eq 'Windows PowerShell ISE Host')) {
return
}
elseif ($psrlMod.Version.Major -lt 2) {
throw "PSReadLine 1.x installed or not imported, import PSRL or ugprade to at least 2.x."
}
@rkeithhill
rkeithhill / ResetColors.ps1
Created January 11, 2015 02:36
Resets the console background and foreground colors to their startup values
# Certains console exes have a tendency to bork the console colors - looking at you
# MSBuild.exe. Either copy/paste this into your profile.ps1 file or dot source it.
$script:origBgColor = $host.ui.rawui.BackgroundColor
$script:origFgColor = $host.ui.rawui.ForegroundColor
function Reset-Colors
{
$host.ui.rawui.BackgroundColor = $origBgColor
$host.ui.rawui.ForegroundColor = $origFgColor
}