Skip to content

Instantly share code, notes, and snippets.

View trackd's full-sized avatar
:shipit:
👻🚀

Andree Renneus trackd

:shipit:
👻🚀
View GitHub Profile
<#
# example usage
class foo {
[secret] $thing
[string] $name
}
$test = [foo]@{
thing = [Secret]::new('supersecretthing')
name = 'bob'
function Send-Completion {
<#
https://github.com/microsoft/terminal/wiki/Experimental-Shell-Completion-Menu
#>
[CmdletBinding()]
param()
try {
$a = [char]7 # BEL, `a
@trackd
trackd / New-TableOfContents.ps1
Last active September 6, 2025 23:04
Excel toc generation
function New-TableOfContents {
<#
.EXAMPLE
$excelfile = 'C:\temp\test.xlsx'
$toc = New-TableOfContents -ExcelFile $excelfile
$toc | Export-Excel -Path $ExcelFile -WorksheetName 'TOC' -Title "Table of Contents" -MoveToStart
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
@trackd
trackd / knuth-plass.ps1
Created June 16, 2025 22:13
dont ask me why, i dont know
add-type -TypeDefinition @'
/// knuth plass c# implementation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Knuth;
public static class LB
{
function ConvertTo-DollarWords {
<#
.EXAMPLE
ConvertTo-DollarWords '$1234.56'
ConvertTo-DollarWords '$1234,56'
ConvertTo-DollarWords '$1.01'
#>
param(
[string] $Amount
)
@trackd
trackd / Write-ProgressBar.ps1
Last active April 30, 2025 20:32
progress bar thing
function Write-ProgressBar {
<#
.NOTES
0 is the default state, and indicates that the progress bar should be hidden. Use this state when the command is complete, to clear out any progress state.
1: set progress value to <progress>, in the "default" state.
2: set progress value to <progress>, in the "Error" state
3: set the taskbar to the "Indeterminate" state. This is useful for commands that don't have a progress value, but are still running. This state ignores the <progress> value.
4: set progress value to <progress>, in the "Warning" state
<progress> is a number between 0 and 100, inclusive
@trackd
trackd / Enable-SSH.ps1
Created October 28, 2024 15:04
enable ssh
function Enable-SSH {
[cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param()
# could just set it to require administrator but that gets annoying if including it in a module.
$CurrentScope = [Security.Principal.WindowsPrincipal]::new([Security.Principal.WindowsIdentity]::GetCurrent())
if (-Not $CurrentScope.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
$PSCmdlet.ThrowTerminatingError(
[System.Management.Automation.ErrorRecord]::new(
function ConvertFrom-MarkdownTable {
<#
.DESCRIPTION
Converts a markdown table to a PowerShell object.
Supports multiple tables in a single markdown document.
Each table is output as an array.
.EXAMPLE
@'
# Fun markdown tables
@trackd
trackd / Show-Object.md
Last active October 28, 2024 22:56
Show-Object

this is just me playing around with [ClassExplorer.Internal._Format] class to make things pretty.
obviously there is a hard requirement for the module ClassExplorer

also note the Internal in the name, this could probably break at any time.

Show-Object

experimental thing.. :)

using namespace System.Management.Automation
using namespace System.Management.Automation.Language
using namespace System.Collections
class CommandInfoTransform : ArgumentTransformationAttribute {
[object] Transform([EngineIntrinsics] $engineIntrinsics, [object] $inputObject) {
if ($inputObject -is [CommandInfo]) {
return $inputObject
}
try {
$gcm = Get-Command "$inputObject" | Select-Object -First 1