Skip to content

Instantly share code, notes, and snippets.

View techthoughts2's full-sized avatar
🕵️‍♂️
Investigating a better artifact workflow

Jake Morrison techthoughts2

🕵️‍♂️
Investigating a better artifact workflow
View GitHub Profile
@techthoughts2
techthoughts2 / pester_parameter_mock
Last active January 5, 2023 04:55
Pester test a command that should be called with certain parameters
# test a command that should be called with certain parameters
#------------------------------------------------------------------------------
It 'should call the API with the expected parameters' {
Mock -CommandName Invoke-RestMethod {
} -Verifiable -ParameterFilter { $Uri -like 'https://api.telegram.org/bot*getStickerSet*' }
# "https://api.telegram.org/bot$BotToken/getStickerSet"
$getTelegramStickerPackInfoSplat = @{
BotToken = $token
StickerSetName = 'STPicard'
}
# use generic list to add objects in a performant way
$starTrekShowInfo = New-Object System.Collections.Generic.List[string]
$starTrekShowInfo.Add('Star Trek: The Next Generation')
# use custom objects for high performance adds of custom object
$choiceArray = New-Object System.Collections.Generic.List[PSCustomObject]
#------------------------------------------------------------------------------
# old method which should no longer be used IAW:
# https://docs.microsoft.com/en-us/dotnet/api/system.collections.arraylist?view=net-6.0
# adding stuff to emtpy array objects quickly
$GetVM={Get-VM | Select-Object -ExpandProperty Name}
$AutoCompleteVM = @{
CommandName = 'New-Foo'
ParameterName = 'VMName'
ScriptBlock = $GetVM
}
Register-ArgumentCompleter @AutoCompleteVM
[string[]]('222.1.3.4','1.2.3.4' | % {[Version]$PSItem} | sort)
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
@techthoughts2
techthoughts2 / settings.json
Last active April 11, 2021 19:54
Current Windows Terminal Settings
// This file was initially generated by Windows Terminal 0.11.1333.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
// C:\Users\user\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
@techthoughts2
techthoughts2 / python.json
Last active April 18, 2024 21:42
Collection of Python Snippets for VSCode
{
"if": {
"prefix": "if",
"body": ["if ${1:expression}:", "\t${2:pass}"],
"description": "Code snippet for an if statement"
},
"if/else": {
"prefix": "if/else",
"body": ["if ${1:condition}:", "\t${2:pass}", "else:", "\t${3:pass}"],
"description": "Code snippet for an if statement with else"
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
// {
// "type": "text",
// "style": "plain",
@techthoughts2
techthoughts2 / ws_setup.ps1
Last active December 3, 2023 17:42
This PowerShell script will setup a fresh workstation with everything needed to sucessfully work and be a DevOps Master day-to-day.
#region installs
# core tech choco installs
$script:chocoCoreTech = @(
# 'vscode' # visual studio code
# 'python' # python
# '7zip' # file archiver with good compression ratio
# 'git' # git for windows
# 'firefox' # firefox browser
)
@techthoughts2
techthoughts2 / az_pwsh.ps1
Created March 24, 2021 01:39
Azure PowerShell
Connect-AzAccount