Skip to content

Instantly share code, notes, and snippets.

@mklement0
mklement0 / Add-NuGetType.ps1
Last active Sep 12, 2021
PowerShell function for experimenting with loading .NET assemblies from NuGet packages that are downloaded and cached on demand
View Add-NuGetType.ps1
<#
Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions)
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/7436c9e4b2f73d7256498f959f0d5a7c/raw/Add-NuGetType.ps1 | iex
@mklement0
mklement0 / Show-Help.ps1
Last active Sep 14, 2021
Wrapper PowerShell function for Get-Help that shows help topics online by default and supports copying URLs of / Markdown links to the online help topics to the clipboard
View Show-Help.ps1
<#
Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions)
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/880624fd665073bb439dfff5d71da886/raw/Show-Help.ps1 | iex
@mklement0
mklement0 / PSReadLineMetaInfoKeyHandler.ps1
Last active Apr 26, 2021
PowerShell sample code that demonstrates a PSReadLine key handler that display meta-information about the command being typed in real time.
View PSReadLineMetaInfoKeyHandler.ps1
<#
License: MIT
Author: Michael Klement <mklement0@gmail.com>
See https://stackoverflow.com/a/67266971/45375 for more information.
#>
# The printable characters to respond to.
@mklement0
mklement0 / Invoke-WithEncoding.ps1
Last active Oct 25, 2021
PowerShell function for invoking native (external) programs with a specified character encoding
View Invoke-WithEncoding.ps1
<#
Prerequisites: PowerShell v3+
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/ef57aea441ea8bd43387a7d7edfc6c19/raw/Invoke-WithEncoding.ps1 | iex
@mklement0
mklement0 / Debug-NativeInOutput.ps1
Last active Oct 17, 2021
PowerShell function for diagnosing character-encoding problems when communication with native (external) programs
View Debug-NativeInOutput.ps1
<#
Prerequisites: PowerShell v3+
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/eac1f18fbe0fc2798b214229b747e5dd/raw/Debug-NativeInOutput.ps1 | iex
@mklement0
mklement0 / Debug-String.ps1
Last active Dec 24, 2021
PowerShell function to visualize control characters and Unicode characters in strings
View Debug-String.ps1
<#
Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions)
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/7f2f1e13ac9c2afaf0a0906d08b392d1/raw/Debug-String.ps1 | iex
@mklement0
mklement0 / Select-StringFormatted.ps1
Last active Apr 28, 2021
PowerShell function that wraps Select-String to make it search the formatted representations of its input objects.
View Select-StringFormatted.ps1
<#
Prerequisites: PowerShell v3+
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/46fea9e6e5ef1a3ceaf681c976cb68e3/raw/Select-StringFormatted.ps1 | iex
@mklement0
mklement0 / Out-HostColored.ps1
Last active Jan 16, 2022
PowerShell function that colors portions of the default host output that match given patterns.
View Out-HostColored.ps1
<#
Prerequisites: PowerShell version 2 or above.
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD, from PowerShell version 3 or above:
irm https://gist.github.com/mklement0/243ea8297e7db0e1c03a67ce4b1e765d/raw/Out-HostColored.ps1 | iex
@mklement0
mklement0 / Use-Culture.ps1
Created Sep 9, 2020
PowerShell script/function that executes a script block with a given culture and UI culture in effect
View Use-Culture.ps1
<#
NOTE:
It is BEST TO DOT-SOURCE (.) THIS SCRIPT, which defines a function of the same
name for later use.
While it is possible to invoke this script directly, its help can then only
be invoked with the -? switch, providing only terse help,
whereas dot-sourcing provides full Get-Help integration.
Similarly, only with dot-sourcing do you get tab completion.
@mklement0
mklement0 / Get-CharInfo.ps1
Last active Apr 28, 2021
PowerShell function that retrieves information about Unicode characters and categories.
View Get-CharInfo.ps1
<#
Prerequisites: PowerShell v3+
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/25694cbb8e10a7044b36a310e1243959/raw/Get-CharInfo.ps1 | iex