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
<#
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 / 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 / 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
@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 / 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 / 1. SSM Document Example.ps1
Last active March 8, 2019 05:48
VaporShell Snippets
# 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 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")]