Skip to content

Instantly share code, notes, and snippets.

@Seekatar
Seekatar / Test-psakeparameters.ps1
Last active April 13, 2020 11:34
Demonstrates the differences in Psake parameters and properties
<#
Order of processing
1. Parameters from commandline are set
2. Properties block is run
3. Properties from command line then set
Use -parameters to add new values to the script you want to use in the properties block
Use -properties to override a value in properties block or add new value
$params = @{
a = 'a from -parameters'
b = 'b from -parameters'
@Seekatar
Seekatar / makeDynamicParam.ps1
Created November 20, 2018 15:43
Helper script for making dynamic parameters in PowerShell
<#
.SYNOPSIS
Helper for making dynamic parameters with ValidateSets in PowerShell
.PARAMETER ParameterName
Name of dynamic parameter
.PARAMETER MakeList
A scriptblock to create the ValidateSet list
@Seekatar
Seekatar / Edit-Object.ps1
Last active July 24, 2019 19:39
Traverse all the properties of a PowerShell object with a visitor scriptblock. The process.json is used as input to the Pester tests.
<#
Class for passing into Edit-Object
#>
class EditObjectVisitor
{
<#
Called by Edit-Object on each member.
$Obj the current object visited
$Member the current member visited
$Path the path to the current member, e.g. obj.array[2].propA
@Seekatar
Seekatar / Get-StoredProcParameters.ps1
Last active September 5, 2019 13:28
Get stored proc names and parameters from the database with PowerShell
<#
.SYNOPSIS
Get JSON out put of SQL Stored Proc names and their parameters
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string] $serverInstance = '.',
[Parameter(Mandatory)]
[string] $database = 'test',
@Seekatar
Seekatar / psakefile.ps1
Last active March 7, 2021 12:12
Psakefile for building, running dotnet app
<#
psakefile for building and running dotnet app in docker
Invoke like this:
Invoke-Psake -buildFile '.\psakefile.ps1' -taskList @($Task) -parameters @{
dockerEnvFile = $DockerEnvFile
dockerTag = $DockerTag
containerName = $ContainerName
nugetUrl = $NugetUrl
@Seekatar
Seekatar / Split-HelmDryRun.ps1
Created February 6, 2021 15:33
Split up Helm dry-run output into separate files to match the template folder
<#
.SYNOPSIS
Split out the manifest files from a helm dryrun for comparing against one another or the Helm /template folder
.PARAMETER line
Lines from --dry-run output
.PARAMETER OutputPath
Existing folder where to put the files
@Seekatar
Seekatar / base64.ps1
Last active March 7, 2021 11:26
PowerShell base64 encode decode
<#
.SYNOPSIS
base64 conversion function
.DESCRIPTION
Convert to and from base64 like Linux base64 utility
.PARAMETER s
File name or string
@Seekatar
Seekatar / ForEach-Git.ps1
Last active July 23, 2023 20:01
PowerShell script to run commands on git repo folders
<#
.SYNOPSIS
Run a scriptblock for all sub folders that are Git repos. Supports -WhatIf, -Confirm
.PARAMETER ScriptBlock
Scriptblock to run for each git Folder. Defaults to $defaultFegScriptBlock which shows status. See Notes for parameters
.PARAMETER HasWorking
Set to true to only run on folders that have 'working' git flag set
@Seekatar
Seekatar / New-AzDoPR.ps1
Created January 25, 2022 21:53
PowerShell script for creating a new PR in Azure DevOps
<#
.SYNOPSIS
Create a new PR
.DESCRIPTION
Long description
.PARAMETER Directory
Source directory of the PR, defaults to current directory
@Seekatar
Seekatar / iTerm2-PowerShell.json
Last active February 13, 2022 00:51
iTerm2 PowerShell Profile configuration. Import this via the iTerm app for macOS. See https://iterm2.com/
{
"Ansi 5 Color" : {
"Green Component" : 0,
"Red Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527
},
"Tags" : [
],
"Ansi 12 Color" : {