Skip to content

Instantly share code, notes, and snippets.

View tmeckel's full-sized avatar
👋
The IT nerd from next door. Passionate about automation

Thomas Meckel tmeckel

👋
The IT nerd from next door. Passionate about automation
View GitHub Profile
@tmeckel
tmeckel / Read-DotEnv.ps1
Created June 10, 2022 16:21
Read .env file with PowerShell
[CmdletBinding(SupportsShouldProcess = $true)]
[OutputType([System.Object[]])]
param(
[Parameter(Position=0, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[string]
$LiteralPath = (Join-Path -Path $PSScriptRoot -ChildPath '.env'),
[Parameter()]
[switch]
@tmeckel
tmeckel / azuread-azurerm-login.md
Created December 11, 2020 19:24
Create non-interactive login for AzureAD PowerShell based on an existing AzureRM login
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext
$aadToken = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($context.Account, `
    $context.Environment, `
    $context.Tenant.Id.ToString(), `
    $null, `
    [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, `
    $null, `
    "https://graph.windows.net").AccessToken
Connect-AzureAD -AadAccessToken $aadToken -AccountId $context.Account.Id -TenantId $context.tenant.id
@tmeckel
tmeckel / VSCodeExtensionList.csv
Last active October 2, 2019 14:30
VSCode: List installed extensions
name displayName Reference
azure-account Azure Account ms-vscode.azure-account
azure-pipelines Azure Pipelines ms-azure-devops.azure-pipelines
bracket-pair-colorizer-2 Bracket Pair Colorizer 2 CoenraadS.bracket-pair-colorizer-2
csharp C# ms-vscode.csharp
csharpextensions C# Extensions jchannon.csharpextensions
cpptools C/C++ ms-vscode.cpptools
codealignment-vscode Code alignment cpmcgrath.codealignment-vscode
vscode-java-debug Debugger for Java vscjava.vscode-java-debug
github-plus-theme GitHub Plus Theme thenikso.github-plus-theme
@tmeckel
tmeckel / Get-GitHubReleases.ps1
Created May 31, 2019 13:51
Get project release numbers from GitHub
[System.Net.ServicePointManager]::SecurityProtocol += 'Tls12'
$owner = 'microsoft' # 'microsoft' # 'golang'
$repo = 'Git-Credential-Manager-for-Windows' #'Git-Credential-Manager-for-Windows' #'go'
$relList = $null
$limitAll = $true
$relUrl = (Invoke-RestMethod -Uri "https://api.github.com/repos/$owner/$repo").releases_url
if ($relUrl) {
$idx = $relUrl.IndexOf('{')
@tmeckel
tmeckel / CreateServerCert.md
Last active June 2, 2019 16:01
Windows: Create new Server Certificate

Create a new Server Certificate

Prerequisite: https://github.com/FiloSottile/mkcert

$env:CAROOT = Join-Path $PSScriptRoot 'CA'
<#
mkcert creates the directory if it does not exist

if (-not (Test-Path $env:CAROOT)) {
@tmeckel
tmeckel / CreateWindowsVMImage.md
Last active December 29, 2018 14:35
Create Windows VM Image (disk)

VirtualBox: Create Windows VM Image (disk)

Important Use a VDI disk. Otherwise VBoxManage.execannot shrink the disk!

  1. Install Windows
  2. sconfig.exe
    a. Set updates to manual
    b. Enabled RDP
@tmeckel
tmeckel / VSCodeTrimTrailingWhitespace.md
Last active October 6, 2018 10:55
VSCode: enable trailing whitespace trimming on save except Markdown files

"files.trimTrailingWhitespace": true, "[markdown]": { "files.trimTrailingWhitespace": false },

@tmeckel
tmeckel / PowershellFindindCommands.md
Created March 6, 2018 09:17
Snippet, Powershell: Finding commands (executables)
$prgMap = @(
    @{
        "Name" = "gacutil.exe"
        "Type" = "Application"
        "DefaultPath" = $PSScriptRoot
        "VariableName" = "cmdGacutil"
    },
    @{
 "Name" = "appcmd.exe"
@tmeckel
tmeckel / VSSyncOpenFileToSoltionExplorer.md
Created February 28, 2018 12:23
Visual Studio: Sync Open File to Solutions Explorer

Visual Studio: Sync Open File to Solutions Explorer

To have the currently open file shown in the solution explorer either use the default Keyboard shortcut

CTRL+[, CTRL+s

Or on an international (non QWERTY) keyboard define a new one using the following procedure

@tmeckel
tmeckel / DisableNETOptimization.md
Last active February 28, 2018 09:27
Disable optimizations during debugging for .NET assemblies

How to disable optimizations when debugging referenced code in assemblies.

In a nutshell, you need to:

  • Start VS with the Environment Variable COMPLUS_ZapDisable=1
  • Disable the VS Hosting Process (.vshost.exe) before you start debugging

Most of the times this isn't enough, because the .NET environment uses the optimization settings for referenced assemblies, regardless of the ZapDisable settings. So the JIT optimizations has to disabled while debugging for such assemblies.