Skip to content

Instantly share code, notes, and snippets.

:shipit:
🚀 🚢 🚂

Nate Ferrell scrthq

:shipit:
🚀 🚢 🚂
View GitHub Profile
View PowerShellGet-PackageManagement-Force_TLS_1.2.ps1
<#
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 Nov 6, 2019
VSCode PowerShell Token Colors per Theme
View OneDark.json
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Italics",
"scope": [
"comment",
"punctuation.definition.comment",
"keyword",
"storage",
@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 Jun 6, 2020
Azure Pipelines Helper Functions
View AzurePipelineHelpers.ps1
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 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")]
You can’t perform that action at this time.