Skip to content

Instantly share code, notes, and snippets.

View Jaykul's full-sized avatar
😀
Learning

Joel Bennett Jaykul

😀
Learning
View GitHub Profile

This is barely worth sharing, but you can, for instance, get everything pinned to the taskbar, and unpin it from the start menu

Get-Application -PinnedToTaskbar | UnpinStart

Huge Caveat: I haven't figured this all out.

  1. I can't figure out a way to get the order of the taskbar items...
  2. Many items don't have the "pin to taskbar" verb when called this way (I don't know why) and you have to do something ridiculous like making a shortcut to them first (thus, the task bar folder) and then pin that.
@Jaykul
Jaykul / EngineEvent.ps1
Last active April 5, 2024 16:45
How to inject text into the NEXT command prompt
$global:Suggestion = Get-Completion "This is my question"
$global:InjectCommand = Register-EngineEvent -SourceIdentifier PowerShell.OnIdle {
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($global:Suggestion)
Stop-Job $global:InjectCommand # This removes the event
}
@Jaykul
Jaykul / Measure-CommandUsage.ps1
Created November 29, 2023 06:03
Let's have a look at what commands we use
[CmdletBinding()]
param(
# Limit the number of results
[int]$Top
)
$Tokens = @()
$Names = @{}
foreach ($history in [Microsoft.PowerShell.PSConsoleReadLine]::GetHistoryItems()) {
$null = [System.Management.Automation.Language.Parser]::ParseInput($history.CommandLine, [ref]$Tokens, [ref]$null)

When I'm having a bad day, I can spend hours just fiddling with colors and recursion ...

Today I wrote an HslEnumerator class which is fun because if you output it to the PowerShell terminal it just goes on producing colors forever:

[HslEnumerator][PoshCode.Pansies.RgbColor]"Goldenrod" | Format-Wide 30 # I do have a wide screen

But I also made something more fun. Out-Colors will colorize tables or lists with fun HSL rainbows...

@Jaykul
Jaykul / Invoke-Native.psm1
Last active January 9, 2024 13:40
Calling native executables that write non-error to stderr (with prefixes like "Warning:" and "Error:") ...
class EncodingAttribute : System.Management.Automation.ArgumentTransformationAttribute {
[object] Transform([System.Management.Automation.EngineIntrinsics]$engineIntrinsics, [object] $inputData) {
if ( $inputData -is [string] ) {
return [Text.Encoding]::GetEncoding($inputData)
} else {
return $inputData
}
}
}
@Jaykul
Jaykul / Get-WebCertificate.ps1
Last active August 5, 2023 23:36
ServerCertificateValidationCallback (or rather, collector) for .NET Core
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[Uri]$url
)
Add-Type -TypeDefinition @'
using System;
using System.Net.Http;
using System.Net.Security;
@Jaykul
Jaykul / About autoscaling node pools in AKS.md
Last active July 18, 2023 19:43
AKS Autoscaling requires CPU quota +1

If you ever see a pod that won't deploy, and it says something like:

Reason: NotTriggerScaleUp
Message: pod didn't trigger scale-up: 1 node(s) had untolerated taint {CriticalAddonsOnly: true}, 1 in backoff after failed scale-up

Don't waste time trying to ask Kubernetes why this failed. Check your scale up settings in the Azure portal, and hit the "Scale node pool" link: image

@Jaykul
Jaykul / Agent Passthru.md
Last active April 18, 2024 11:18
SSH Agent passthru to WSL 2 (working, in Windows 11, in May 2023)

For awhile now, each time I got a new Windows laptop I would dig up strasis gist on how to set up agent forwarding for SSH in WSL2 -- but recently I tried to point someone else at it and they were very confused by it, so this is my attempt at simpler instructions.

Installation

With Chocolatey, you must use an elevated PowerShell session. If there's no choco command found, it will fall back to winget for the npiperelay install. To force using Winget even if you have choco installed, you need to download it, so you can pass parameters to it.

Easy mode: just run this in PowerShell:

@Jaykul
Jaykul / About Copilot CLI.md
Created April 30, 2023 22:55
Copilot CLI in PowerShell

We are, for now, just using the official github copilot CLI, but they didn't really have hooks for PowerShell, so I wrote a few functions to implement it.

It works great, as you can see:

a simple prompt for how to find the top 10 files

the modified query, executed

@Jaykul
Jaykul / Darkly.theme.psd1
Last active April 30, 2023 21:12
EzThemes
@{
PowerLine = (PSObject @{
Colors = @((RgbColor '#333333'), (RgbColor '#424242'), (RgbColor '#8A8A8A'), (RgbColor '#707070'))
FullColor = $True
PowerLineCharacters = @{
Separator = ''
ColorSeparator = ''
ReverseSeparator = ''
ReverseColorSeparator = ''