Skip to content

Instantly share code, notes, and snippets.

View Jaykul's full-sized avatar
😀
Learning

Joel Bennett Jaykul

😀
Learning
View GitHub Profile
@lzybkr
lzybkr / Convert-ArgumentCompleterRegistrationScript.ps1
Created April 27, 2015 18:41
Script to convert TabExpansion++ completers to use Register-ArgmentCompleter
param(
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory, Position = 0)]
[Alias("PSPath")]
[string]$Path,
[string]$OutputPath
)
process
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class NativeConsoleMethods
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr GetStdHandle(int handleId);
@bielawb
bielawb / CompleteShould.ps1
Created November 29, 2016 18:44
TabExpansion for Should
Register-ArgumentCompleter -Native -CommandName Should -ScriptBlock {
param ($WordToComplete, $CommandAst)
$options = @(
'Be'
'BeExactly'
'BeLike'
'BeGreaterThan'
'BeLessThan'
'Contain'
'Match'
@msnelling
msnelling / Install-Miniconda.ps1
Created December 16, 2016 09:01
Installs Miniconda from extracted .exe installer
param(
[string]$Exe7z,
[string]$PackageDir,
[string]$InstallDir
)
Function Expand-ToDirectory {
param(
[string]$Archive,
[string]$TargetDir
@lnattrass
lnattrass / get_tds_cert.py
Last active February 6, 2025 23:30
A terrible way to connect to MS SQL Server and dump the certificate as a PEM
import sys
import pprint
import struct
import socket
import ssl
from time import sleep
# Standard "HELLO" message for TDS
prelogin_msg = bytearray([ 0x12, 0x01, 0x00, 0x2f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x06, 0x01, 0x00, 0x20,
0x00, 0x01, 0x02, 0x00, 0x21, 0x00, 0x01, 0x03, 0x00, 0x22, 0x00, 0x04, 0x04, 0x00, 0x26, 0x00,
@amandadebler
amandadebler / BootlegPowerShellGet.psm1
Last active October 16, 2019 18:34 — forked from Jaykul/PowerShellGet.psm1
PowerShell Gallery Module - Bootleg Edition
<#
Forked from https://github.com/jaykul Gist, posted in response to my Twitter
whinge about PowerShellGet in the enterprise - Thank you, Joel Bennett!
This adds the ability to use a web proxy, using your current session's
credentials. Might add option to use other credentials, if there's demand.
It also adds a 'BL' (Bootleg) prefix to the nouns, just to prevent confusion with the "real"
cmdlets. Feel free to remove them.
Set-PowerLinePrompt `
-SetCurrentDirectory `
-RestoreVirtualTerminal `
-PowerLineFont `
-FullColor `
-Title {
$title = "PowerShell {0} - {1} ({2}) - PID: {3}" -f $PSVersionTable.PSVersion.ToString(),(Convert-Path $pwd), $pwd.Provider.Name,$PID
if (Test-Elevation) {
"Elevated - $title"
} else {
@Jaykul
Jaykul / Trace-Dependency.ps1
Last active October 6, 2022 09:38
Extract a list of commands used by a script or script command. Will warn about commands it can't identify and put them in global `$MissingCommands` variable.
#requires -Module Reflection
[CmdletBinding()]
param(
# The path to a script or name of a command
$Command,
# If you want to include private functions from a module, make sure it's imported, and pass the ModuleInfo here
[System.Management.Automation.PSModuleInfo]$ModuleScope = $(
Get-Module $Command -ListAvailable -ErrorAction SilentlyContinue | Get-Module -ErrorAction SilentlyContinue
),
@Agazoth
Agazoth / Get-MonitorInfo.ps1
Last active April 15, 2023 23:24
Iron Scripter 2018 Puzzle 1 for multiple machines
function Get-MonitorInfo {
[CmdletBinding()]
param ([string[]]$ComputerNames = $env:computername)
foreach ($ComputerName in $ComputerNames){
try {
$CimSession = New-CimSession -ComputerName $ComputerName
} catch {
Write-Warning "Please make sure PSRemoting is enabled on $ComputerName"
Continue
}
using namespace System.Management.Automation
using namespace System.Collections.Generic
class ArgumentCompleterBase : IArgumentCompleter {
hidden [List[CompletionResult]] $Results = [List[CompletionResult]]::new()
[string] $WordToComplete
[Language.CommandAst] $commandAst
# override in child class
[void] AddCompletionsFor([string] $commandName, [string] $parameterName, [Collections.IDictionary] $fakeBoundParameters) {}