Skip to content

Instantly share code, notes, and snippets.

View scrthq's full-sized avatar
☁️
daydreaming of pipelines and standards

Nate Ferrell scrthq

☁️
daydreaming of pipelines and standards
View GitHub Profile
@scrthq
scrthq / git.aliases.ps1
Created January 25, 2019 21:35
Handy Git Aliases
# Run from PowerShell
$aliasList = @(
"a = !git add . && git status"
"aa = !git add . && git add -u . && git status"
"ac = !git add . && git commit"
"acm = !git add . && git commit -m"
"alias = !git config --get-regexp '^alias\.' | sort"
"amend = !git add -A && git commit --amend --no-edit"
"au = !git add -u . && git status"
@scrthq
scrthq / AzurePipelineHelpers.ps1
Last active January 11, 2021 05:07
Azure Pipelines Helper Functions
Param(
[Parameter(Position = 0)]
[String]
$ProjectName = $(Split-Path $PWD.Path -Leaf)
)
$env:_BuildStart = Get-Date -Format 'o'
New-Variable -Name IsCI -Value $($IsCI -or (Test-Path Env:\TF_BUILD)) -Scope Global -Force -Option AllScope
<#
Some proxy commands to add to your profile to force the following functions/cmdlets
to use TLS 1.2 without changing the SecurityProtocol for your entire session:
- Update-Module
- Install-Module
- Install-PackageProvider
Context: https://twitter.com/Steve_MSFT/status/1248396676017995779
Sample usage:
@scrthq
scrthq / OneDark.json
Created November 6, 2019 17:15
VSCode PowerShell Token Colors per Theme
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Italics",
"scope": [
"comment",
"punctuation.definition.comment",
"keyword",
"storage",
@scrthq
scrthq / Current Prompt.ps1
Last active August 21, 2019 06:17
PowerShell Profile + Prompt
try {
Import-Module posh-git -ErrorAction Stop
}
catch {
Install-Module posh-git -Scope CurrentUser -Repository PSGallery
Import-Module posh-git
}
function Get-PSVersion {
<#
.SYNOPSIS
@scrthq
scrthq / Backgrounder.Class Examples.ps1
Created July 29, 2019 14:23
Backgrounding tasks in PowerShell classes using either the PoshRSJob and ThreadJob module
class Backgrounder {
[string[]] $Updates
Backgrounder(){}
[void] AddUpdate([string]$update) {
$this.Updates += $update
}
[void] Update() {
1..5 | ForEach-Object {
# ThreadJob
Start-ThreadJob -Name {$_} -ArgumentList $_ -ScriptBlock {
@scrthq
scrthq / VSCode - TokenColors.json
Created July 28, 2019 18:03
VSCode Settings to use with the One Dark Pro theme to complete colorization of PowerShell tokens and add some extra fanciness. Use with theme: https://marketplace.visualstudio.com/items?itemName=zhuangtongfa.Material-theme
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Italics",
"scope": [
"comment",
"punctuation.definition.comment",
"keyword",
"storage",
"entity.other.attribute-name",
@scrthq
scrthq / Convert-Duration.ps1
Last active June 10, 2019 18:56
Converts a TimeSpan or ISO8601 duration string to the desired output type.
function Convert-Duration {
<#
.SYNOPSIS
Converts a TimeSpan or ISO8601 duration string to the desired output type.
.DESCRIPTION
Converts a TimeSpan or ISO8601 duration string to the desired output type.
More info on ISO8601 duration strings: https://en.wikipedia.org/wiki/ISO_8601#Durations
@scrthq
scrthq / PowerShell Profile Components.ps1
Last active June 1, 2019 19:09
PowerShell Profile components
<#
This is my ever growing collection of PowerShell / workstation configuration bits.
#>
@scrthq
scrthq / Update-Release.ps1
Last active May 19, 2019 07:44
Azure DevOps / VSTS - API PowerShell functions
function Update-Release {
[CmdletBinding(DefaultParameterSetName = "UseDefaultCredentials")]
Param (
[parameter(Mandatory = $true,ParameterSetName = "PAT")]
[String]
$User,
[parameter(Mandatory = $true,ParameterSetName = "PAT")]
[String]
$PersonalAccessToken,
[parameter(Mandatory = $false,ParameterSetName = "UseDefaultCredentials")]