Skip to content

Instantly share code, notes, and snippets.

View dennisroche's full-sized avatar
🐱

Dennis Roche dennisroche

🐱
View GitHub Profile
@dennisroche
dennisroche / Peek-Cmdlet.ps1
Last active February 22, 2024 19:59
Reflect Powershell CmdLet using Jetbrains DotPeek
function Peek-Cmdlet {
param(
[Management.Automation.CommandInfo]$command
)
if ($input) {
trap { $_; break }
$command = $input | select -first 1
}
@dennisroche
dennisroche / README.md
Last active October 21, 2022 04:17
Pretty log header using ASCII
  ╔═══════════════════════════════════════════════════════════════════════════════╗
  ║                                    Example                                    ║
  ╚═══════════════════════════════════════════════════════════════════════════════╝

Useful for breaking up large log files

@dennisroche
dennisroche / cfn-http2-target-group.py
Last active February 12, 2021 01:53
CloudFormation custom resource to create HTTP2 Target Group
'''
Uses crhelper https://github.com/aws-cloudformation/custom-resource-helper
Requires
- 'elasticloadbalancing:*'
- 'ec2:DescribeInternetGateways'
- 'ec2:DescribeVpcs'
'''
from crhelper import CfnResource
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
@dennisroche
dennisroche / posh-cntlm.ps1
Last active January 30, 2020 15:46
Powershell script that sets your Internet Proxy settings and npm (if found) and auto-restarts Cntlm Authenication Proxy
#Requires -RunAsAdministrator
[CmdletBinding()]
param()
$ErrorActionPreference = "Stop"
trap
{
Pop-Location
Write-Error "$_"
Exit 1
@dennisroche
dennisroche / RunPSAsAdministrator.bat
Created May 3, 2016 01:50
Powershell, Add 'Run As Administrator' to right-click menu
@ECHO OFF
TITLE Enable right-click 'Run as Admin' for PowerShell
ECHO.
ECHO Enabling right-click 'Run as Admin' for PowerShell
ECHO.
:: Add value for UAC shield icon:
REG ADD "HKCR\Microsoft.PowerShellScript.1\Shell\runas" /v HasLUAShield /t REG_SZ /d "" /f
:: Add value to create context menu item:
@dennisroche
dennisroche / PromoteAll.ps1
Created April 5, 2018 05:01
Octopus Deploy script to shift a range of projects to the right (dev to staging) as a set
$octo = Get-OctopusTools
Write-Heading 'Projects'
function GetProjectsInGroup([string]$projectGroupName, [string]$ignoreProjectNames) {
$projectGroup = Invoke-OctopusApi '/api/projectgroups/all' | Where-Object { $_.Name -eq $projectGroupName }
if ($null -eq $projectGroup) {
Write-Fatal "Project $projectGroupName not found"
}
@dennisroche
dennisroche / ValidateAzureTemplate.ps1
Created April 5, 2018 04:59
Validate Azure ARM template
function Format-ValidationOutput {
Param (
[Parameter(ValueFromPipeline=$true)] $ValidationOutput,
[int] $Depth = 0
)
return @($ValidationOutput | Where-Object { $_ -ne $null } | ForEach-Object { @(' ' * $Depth + ': ' + $_.Message) + @(Format-ValidationOutput @($_.Details) ($Depth + 1)) })
}
# Template
@dennisroche
dennisroche / PostDeploySql.ps1
Created April 5, 2018 04:58
PostDeploy script for Octopus that executes SQL
trap {
Write-Error "$_"
Exit 1
}
# Injected by Octopus Deploy Step Template
$connectionString = $DeploySqlConnectionString
$filter = $Filter
Write-Host "Executing scripts in folder '$($PSScriptRoot)'"
@dennisroche
dennisroche / LoadAzureCertificate.ps1
Created April 5, 2018 04:56
Loading a Certificate to Azure (useful for IdentityServer)
$pfx = $OctopusParameters["PrimarySigningCertificate.Pfx"]
$thumbprint = $OctopusParameters["PrimarySigningCertificate.Thumbprint"]
$appName = "auth-api-$AzureEnvironment"
function Set-AzureRmCertificate($ResourceGroupName, $Location, $Pfx, $Thumbprint) {
$ResourceLocation = $Location
$ResourceName = $Thumbprint
$PropertiesObject = @{
pfxBlob = $Pfx;
password = ""