Skip to content

Instantly share code, notes, and snippets.

Avatar
🕵️‍♂️
Investigating a better artifact workflow

Jake Morrison techthoughts2

🕵️‍♂️
Investigating a better artifact workflow
View GitHub Profile
View bs-powershell
- dotnet tool install --global PowerShell --version 7.0.3
- powershell -command '.\configure_aws_credential.ps1'
# - aws s3 cp s3://ps-invoke-modules/PowerShell-7.0.3-win-x64.msi PowerShell-7.0.3-win-x64.msi --quiet
- powershell -command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;$url = """https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell-7.0.3-win-x64.msi""";$output = """$env:CODEBUILD_SRC_DIR\PowerShell-7.0.3-win-x64.msi""";Invoke-WebRequest -Uri $url -OutFile $output -ErrorAction Stop;if (-not(Test-Path $output)) {throw """PSCore failed to DL"""}'
- powershell -command "Start-Process $env:CODEBUILD_SRC_DIR\PowerShell-7.0.3-win-x64.msi -ArgumentList '/qn /norestart' -Wait"
- '& "C:\Program Files\PowerShell\7\pwsh.exe" -command ''.\install_modules.ps1'''
@techthoughts2
techthoughts2 / settings.json5
Last active Sep 26, 2020
Visual Studio Code User Settings that I currently use. Heavy focus on PowerShell, Python, and AWS Cloudformation.
View settings.json5
{
//SETTINGS CHANGES
"breadcrumbs.enabled": false,
"explorer.confirmDragAndDrop": false,
"omnisharp.projectLoadTimeout": 120,
"workbench.settings.editor": "json",
"workbench.tree.indent": 15,
"workbench.editor.titleScrollbarSizing": "large",
//LOOK AND FEEL CHANGES
//editor
View keybindings
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+shift+c",
"command": "PowerShell.ShowAdditionalCommands",
"when": "editorLangId == 'powershell'"
},
{
"key": "ctrl+shift+t",
"command": "shellLauncher.launch"
@techthoughts2
techthoughts2 / vs_code_extensions
Last active Sep 26, 2020
List of Visual Studio Code extensions that I am currently using. Heavy focus with PowerShell development and AWS CloudFormation.
View vs_code_extensions
<#
aaron-bond.better-comments
amazonwebservices.aws-toolkit-vscode
aws-scripting-guy.cform
ban.spellright
bierner.markdown-preview-github-styles
CoenraadS.bracket-pair-colorizer-2
DanielThielking.aws-cloudformation-yaml
DavidAnson.vscode-markdownlint
DotJoshJohnson.xml
View PSProfile
#region functions
<#
.SYNOPSIS
Clears all errors, variables, console, and sets locations back to C:\
.NOTES
System variables are not cleared - as they are gathered previously and left un-touched.
#>
function Clear-All {
$sysvariables = $sysvars
View Microsoft.VSCode_profile
#Microsoft.VSCode_profile.ps1
Write-Host -ForegroundColor Gray ("Loading up the EditorServicesCommandSuite...")
try {
# Place this in your VSCode profile
Import-Module EditorServicesCommandSuite
Import-EditorCommand -Module EditorServicesCommandSuite
Write-Host "EditorServicesCommandSuite loaded." -ForegroundColor Magenta
}
catch{
Write-Host "Jake, EditorServicesCommandSuite has failed." -ForegroundColor DarkRed
@techthoughts2
techthoughts2 / ps_reddit
Last active Jul 3, 2020
PowerShell based interactive reddit browser. Browse your favorite subreddits using PowerShell!
View ps_reddit
<#
.SYNOPSIS
Launches the default browser to display reddit pictures.
.DESCRIPTION
Long description
.EXAMPLE
Show-Pics -URL https://i.imgur.com/fcuRqwl.jpg
Launches default browser to provided link.
.EXAMPLE
@techthoughts2
techthoughts2 / CustomPSObject
Last active Jun 11, 2020
Several examples of creating and working with custom PowerShell objects and hash tables. Examples include creating customer Powershell objects that contain multiple values.
View CustomPSObject
#Jake Morrison - @jakemorrison - http://techthoughts.info
$results = [PSCustomObject]@{
HypTotal = $hyptotal
MgmtVMTotal = $mgmtVMTotal
UniqueCustomerCount = $customerTotal
TotalComputerObjects = $allCompsTotal
TotalUserObjects = $userTotal
}
View argument_completer
function test-arg {
[cmdletbinding()]
param(
[ArgumentCompleter({'mouse','house','goat'})]
$GreenEggs
)
$greeneggs
}
@techthoughts2
techthoughts2 / ps_Errors.ps1
Last active Feb 17, 2020
Working with PowerShell Errors
View ps_Errors.ps1
function Reset-Errors {
$Global:Error.Clear()
$psISE.Options.ErrorForegroundColor = '#FFFF0000'
$Global:ErrorView = 'NormalView'
}
Reset-Errors
#generate an error
function Show-Error {
Get-Item c:\doesnotexist.txt
You can’t perform that action at this time.