Skip to content

Instantly share code, notes, and snippets.

View mattcargile's full-sized avatar

Matt Cargile mattcargile

  • Baton Rouge, LA
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Management.Automation;
using Microsoft.PowerShell.Commands;
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class CmdletWithPathBase : PSCmdlet
@Jaykul
Jaykul / gcixel.ps1
Created September 1, 2024 04:55
ImageMagick and Sixels -- this is not fast, but it works even across ssh
<#
.SYNOPSIS
gcixels is like gci, but with sixels...
.DESCRIPTION
Shows thumbnails of images with titles, directly in terminal.
However, it's done with ImageMagick montage, so it's awfully slow.
Just sharing it for your inspiration.
.NOTES
Requires ImageMagick and a Sixel terminal (like Windows Terminal 1.22+ or WezTerm)
#>
@jborean93
jborean93 / New-ScheduledTaskSession.ps1
Last active September 21, 2024 10:58
Creates a PSSession that targets a scheduled task process
# Copyright: (c) 2024, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function New-ScheduledTaskSession {
<#
.SYNOPSIS
Creates a PSSession for a process running as a scheduled task.
.DESCRIPTION
Creates a PSSession that can be used to run code inside a scheduled task
@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.. :)

# Here's tiny clipboard sugar for a profile
# context: there was a thread about creating a custom clipboard uri, and clipboard cmdlets
# <https://discord.com/channels/180528040881815552/447476117629304853/1260981998479081562>
Import-Module Pansies
# It's nice to get a confirmation that your clip was saved
$PSDefaultParameterValues['Set-ClipBoard:PassThru'] = $true
Set-alias 'cl' 'Set-ClipBoard' # 'sc' already exists
Set-Alias 'gcl' 'Get-Clipboard'
@jborean93
jborean93 / Split-ExeArgument.ps1
Last active August 19, 2024 19:40
Splits the input string using the Win32 argument splitter
# Copyright: (c) 2024, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
#Requires -Module Ctypes
Function Split-ExeArgument {
[OutputType([string])]
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
@jborean93
jborean93 / Get-FileProcess.ps1
Created May 30, 2024 23:18
Gets the process ids that has the requested file(s) opened
# Copyright: (c) 2024, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
#Requires -Module Ctypes
#Requires -Version 7.3
Function Get-FileProcess {
<#
.SYNOPSIS
Get the process that has opened the requested file.
function Get-BoundParameters {
<#
.DESCRIPTION
Get-BoundParameters is a helper function that returns a hashtable of the bound parameters of the calling function.
difference between $PSBoundParameters is that it gets default value from param block as well.
.PARAMETER IncludeCommon
include the common parameters
@santisq
santisq / method1.ps1
Last active September 16, 2024 21:43
bind default values to `$PSBoundParameters`
& {
[CmdletBinding(DefaultParameterSetName = 'A')]
param(
[Parameter(ParameterSetName = 'A')]
$ParamA = 'A',
[Parameter(ParameterSetName = 'B')]
$ParamB = 'B',
[Parameter(Mandatory)]
$ParamBoth
)
@jborean93
jborean93 / NoGui.ps1
Last active December 23, 2024 00:46
Generates an exe called NoGui.exe that can spawn a hidden windows
<#
NOTE: Must be run in Windows PowerShell (5.1), PowerShell (7+) cannot create standalone exes.
This is designed to create a simple exe that can be used to spawn any console
application with a hidden Window. As NoGui.exe is a GUI executable it won't
spawn with an associated console window and can be used to then create a new
process with a hidden console window with the arguments it was created with.
The arguments after -- will be used as the new process, for example
C:\path\NoGui.exe -- pwsh.exe