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.
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.
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 | |
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 |
function Get-InvocationStatement { | |
[cmdletbinding()] | |
param( | |
[object] $Statement = $MyInvocation.Statement | |
) | |
$tokens = $null | |
$psb = [ordered]@{} | |
$null = [System.Management.Automation.Language.Parser]::ParseInput($Statement, [ref] $tokens, [ref] $null) | |
$filteredTokens = $tokens | Where-Object { $_.Kind -in @('Variable','SplattedVariable','Parameter') } | |
for ($i = 0; $i -lt $filteredTokens.Count; $i++) { |
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' |
# 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 |
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. |