Skip to content

Instantly share code, notes, and snippets.

@mklement0
mklement0 / Invoke-WithEncoding.ps1
Last active September 7, 2023 18:59
PowerShell function for invoking native (external) programs with a specified character encoding
<#
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 September 7, 2023 18:59
PowerShell function for diagnosing character-encoding problems when communication with native (external) programs
<#
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 August 24, 2023 06:40
PowerShell function to visualize control characters and Unicode characters in strings
<#
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 April 28, 2021 23:06
PowerShell function that wraps Select-String to make it search the formatted representations of its input objects.
<#
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 March 9, 2024 20:55
PowerShell function that colors portions of the default host output that match given patterns.
<#
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 September 9, 2020 23:03
PowerShell script/function that executes a script block with a given culture and UI culture in effect
<#
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 December 9, 2023 23:02
PowerShell function that retrieves information about Unicode characters and categories.
<#
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
@mklement0
mklement0 / Show-TypeHelp.ps1
Last active January 29, 2023 20:30
PowerShell function for performing online documentation lookups for built-in .NET types and their members - see https://stackoverflow.com/a/59324892/45375
<#
Prerequisites: PowerShell v3+
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/50a1b101cd53978cd147b4b138fe6ef4/raw/Show-TypeHelp.ps1 | iex
@mklement0
mklement0 / Show-OperatorHelp.ps1
Last active September 24, 2021 20:52
PowerShell function for performing online documentation lookups for PowerShell's operators and operator-like symbols - see https://stackoverflow.com/a/59324892/45375
<#
Prerequisites: PowerShell v3+
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/146f3202a810a74cb54a2d353ee4003f/raw/Show-OperatorHelp.ps1 | iex
@mklement0
mklement0 / Touch-File.ps1
Last active October 4, 2023 19:25
PowerShell function that provides functionality similar to the Unix touch utility for updating last-modified file timestamps and creating files on demand.
<#
Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions)
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and INSTANT DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/82ed8e73bb1d17c5ff7b57d958db2872/raw/Touch-File.ps1 | iex