Skip to content

Instantly share code, notes, and snippets.

@dopyrory3
dopyrory3 / Use-Env.psm1
Created August 12, 2025 17:31
Used for loading env files in PowerShell scripts, useful for locally developing scripts meant to run in Azure DevOps
function Use-Env {
<#
.SYNOPSIS
Loads environment variables from a .env file into the PowerShell session.
.DESCRIPTION
This function reads a .env file in the current directory and sets environment variables in the Power
session. It supports comments and blank lines.
.EXAMPLE
Use-Env
Loads environment variables from the .env file in the current directory.
@dopyrory3
dopyrory3 / Get-ConsoleHandle.ps1
Last active September 29, 2021 15:23
Gets the window handle of the current running PowerShell console, compatible with Windows Terminal
function Get-ConsoleHandle {
Add-Type -TypeDefinition @"
using System;
using System.Windows.Forms;
public class Win32Window : IWin32Window
{
private IntPtr _hWnd;
public Win32Window(IntPtr handle)
function ssh-copy-id {
param (
# Username to use for the SSH connection
[Parameter(Mandatory = $true,
Position = 0,
ValueFromPipeline = $true,
HelpMessage = "Username to use for the SSH connection",
ValueFromPipelineByPropertyName = $true)]
[string]
$Username,