Skip to content

Instantly share code, notes, and snippets.

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
function Get-NerdFontGlyphs {
<#
.SYNOPSIS
Get a list of all Nerd Font Glyphs
.EXAMPLE
Get-NerdFontIcons
.EXAMPLE
Get-NerdFontIcons -AsHashtable
.PARAMETER AsHashtable
Return the list as a hashtable
function Measure-ChildItem {
<#
.SYNOPSIS
Recursively measures the size of a directory.
.DESCRIPTION
Recursively measures the size of a directory.
Measure-ChildItem uses win32 functions, returning a minimal amount of information to gain speed. Once started, the operation cannot be interrupted by using Control and C. The more items present in a directory structure the longer this command will take.
This command supports paths longer than 260 characters.
function Get-MyDisk {
[CmdletBinding()]
param(
[string] $FriendlyName
)
foreach ($Disk in (Get-Disk @PSBoundParameters)) {
foreach ($Partition in (Get-Partition $Disk.Number)) {
foreach ($Volume in (Get-Volume -Partition $Partition)) {
[PSCustomObject]@{
PSTypeName = 'Custom.MyDisk'
@trackd
trackd / Get-WTSSessionInfo.ps1
Last active March 26, 2024 11:50 — forked from jborean93/Get-WTSSessionInfo.ps1
Tries to replicate qwinsta but return structured objects
# Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
namespace Wtsapi32
{
public enum WtsConnectState
@trackd
trackd / ConvertTo-MarkdownTable.ps1
Last active April 12, 2024 15:46
ft as markdowntable
function ConvertTo-MarkdownTable {
<#
.DESCRIPTION
Convert an object to a markdown table.
.PARAMETER InputObject
The object to convert to a markdown table.
.PARAMETER Property
The properties to display in the table.
function Get-PowershellDLEHint {
$iwr = (Invoke-WebRequest 'https://powershelldle.com/').Content
$strings = ($iwr | Select-String -Pattern '<div id="answer-char" class="(relative bottom-1)?">\s*[_-]\s*</div>' -AllMatches).Matches.Value
$verb, $noun = ($strings -replace '<[^>]+>').Trim() -join '' -split '-'
Get-Command | Where-Object { $_.Verb.Length -eq $verb.length -And $_.Noun.Length -eq $noun.length }
}
function Get-TableData {
<#
ls | ft | Get-TableData
.NOTES
https://gist.github.com/Jaykul/9999be71ee68f3036dc2529c451729f4
#>
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
$FormatStartData
@trackd
trackd / Get-AnsiEscape.ps1
Last active May 5, 2024 11:12
something
Update-TypeData -TypeName '_RegexAnsi' -MemberType ScriptMethod -MemberName ToString -Force -Value {
return ($this.Value ? $this.value : $this.Text)
}
Update-TypeData -TypeName 'System.Management.Automation.Internal.StringDecorated' -MemberType ScriptMethod -MemberName ToString -Force -Value {
return $this.IsDecorated
}
function Get-AnsiEscape {
<#
.DESCRIPTION
Get-AnsiEscape can be used to strip, escape, or regex VT codes from a string.
function Enable-DebugSpectre {
[cmdletbinding()]
param()
$moduleName = 'PwshSpectreConsole'
$module = Get-Module -Name $ModuleName
if (-Not $Module) {
$Module = Import-Module $ModuleName -PassThru
}
$new = {
param(