🕵️♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the command name | |
$CommandName = $PSCmdlet.MyInvocation.InvocationName; | |
# Get the list of parameters for the command | |
$ParameterList = (Get-Command -Name $CommandName).Parameters; | |
# Grab each parameter value, using Get-Variable | |
foreach ($Parameter in $ParameterList) { | |
Get-Variable -Name $Parameter.Values.Name -ErrorAction SilentlyContinue; | |
#Get-Variable -Name $ParameterList; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$GetVM={Get-VM | Select-Object -ExpandProperty Name} | |
$AutoCompleteVM = @{ | |
CommandName = 'New-Foo' | |
ParameterName = 'VMName' | |
ScriptBlock = $GetVM | |
} | |
Register-ArgumentCompleter @AutoCompleteVM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[string[]]('222.1.3.4','1.2.3.4' | % {[Version]$PSItem} | sort) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$help": "https://aka.ms/terminal-documentation", | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"actions": | |
[ | |
{ | |
"command": | |
{ | |
"action": "copy", | |
"singleLine": false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", | |
"blocks": [ | |
{ | |
"type": "prompt", | |
"alignment": "left", | |
"segments": [ | |
// { | |
// "type": "text", | |
// "style": "plain", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
) |