Skip to content

Instantly share code, notes, and snippets.

:shipit:
🚀 🚢 🚂

Nate Ferrell scrthq

:shipit:
🚀 🚢 🚂
Block or report user

Report or block scrthq

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@scrthq
scrthq / Backgrounder.Class Examples.ps1
Created Jul 29, 2019
Backgrounding tasks in PowerShell classes using either the PoshRSJob and ThreadJob module
View Backgrounder.Class Examples.ps1
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 Jul 28, 2019
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
View VSCode - TokenColors.json
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Italics",
"scope": [
"comment",
"punctuation.definition.comment",
"keyword",
"storage",
"entity.other.attribute-name",
@scrthq
scrthq / AzurePipelineHelpers.ps1
Last active Sep 5, 2019
Azure Pipelines Helper Functions
View AzurePipelineHelpers.ps1
Param(
[Parameter(Mandatory,Position = 0)]
[String]
$ProjectName
)
$env:_BuildStart = Get-Date -Format 'o'
New-Variable -Name IsCI -Value $($IsCI -or (Test-Path Env:\TF_BUILD)) -Scope Global -Force -Option AllScope
@scrthq
scrthq / Convert-Duration.ps1
Last active Jun 10, 2019
Converts a TimeSpan or ISO8601 duration string to the desired output type.
View Convert-Duration.ps1
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 Jun 1, 2019
PowerShell Profile components
View PowerShell Profile Components.ps1
<#
This is my ever growing collection of PowerShell / workstation configuration bits.
#>
@scrthq
scrthq / Current Prompt.ps1
Last active Aug 21, 2019
PowerShell Profile + Prompt
View Current Prompt.ps1
try {
Import-Module posh-git -ErrorAction Stop
}
catch {
Install-Module posh-git -Scope CurrentUser -Repository PSGallery
Import-Module posh-git
}
function Get-PSVersion {
<#
.SYNOPSIS
View 1. SSM Document Example.ps1
# Recreation of the example found here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ssm-document.html
$ssmDocContent = [PSCustomObject]@{
schemaVersion = "1.2"
description = "Join instances to an AWS Directory Service domain."
parameters = @{
directoryId = @{
type = "String"
description = "(Required) The ID of the AWS Directory Service directory."
}
@scrthq
scrthq / Update-Release.ps1
Last active May 19, 2019
Azure DevOps / VSTS - API PowerShell functions
View Update-Release.ps1
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")]
@scrthq
scrthq / git.aliases.ps1
Created Jan 25, 2019
Handy Git Aliases
View git.aliases.ps1
# 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 / Rename-Subtitles
Created Mar 27, 2018
Quick function to rename subtitle files for Plex subtitle cleanup jobs to remove duplicate locale's. Assumes you are only using a single locale for subs. Defaults to English and SRT extension.
View Rename-Subtitles
function Rename-Subtitles {
[CmdletBinding()]
Param
(
[parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true)]
[ValidateScript({Test-Path $_})]
[String]
$Path,
[parameter(Mandatory = $false)]
[String]
You can’t perform that action at this time.