Skip to content

Instantly share code, notes, and snippets.

@mklement0
mklement0 / Show-Help.ps1
Last active May 8, 2024 01:02
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
<#
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 / Test-WinCredential.ps1
Last active April 18, 2024 01:33
Test-WinCredential: PowerShell function for validating Windows domain / local user credentials.
<#
Prerequisites: Windows PowerShell 5.1, PowerShell (Core) (v6+) - MAY 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/83e8e6a2b39ecec7b0a14a8e631769ce/raw/Test-WinCredential.ps1 | iex
@mklement0
mklement0 / IniFileHelper.psm1
Last active March 30, 2024 12:03
PowerShell module for reading and writing INI files on Windows, via the Windows API
<#
Windows-only module for reading from / updating INI files, via the Windows API.
You can either:
* download this script module (IniFileHelper.psm1) and use Import-Module to import it into a session;
If you place it in a subdirectory named IniFileHelper in in one of the directories listed in $env:PSModulePath,
it will automatically be available in future sessions.
* for ad-hoc use, download the code and create a dynamic, transient module for the
@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 / Enter-AdminPSSession.ps1
Last active January 29, 2024 11:52
Universal PowerShell script (PSv3+) that enters an admin (elevated) session on the local computer and optionally executes commands unattended
<#
Prerequisites: PowerShell v3+
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/f726dee9f0d3d444bf58cb81fda57884/raw/Enter-AdminPSSession.ps1 | iex
@mklement0
mklement0 / Add-NuGetType.ps1
Last active January 10, 2024 18:59
PowerShell function for experimenting with loading .NET assemblies from NuGet packages that are downloaded and cached 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 DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/7436c9e4b2f73d7256498f959f0d5a7c/raw/Add-NuGetType.ps1 | iex
@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 / Get-WinError.ps1
Last active December 9, 2023 22:32
PowerShell function that looks up information about Windows errors, including HRESULT values, by number or name.
<#
Prerequisites: Windows PowerShell v5.1 or PowerShell Core (v6+)
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and INSTANT DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/0fc086da1af9a72a94cbdb4a59d55230/raw/Get-WinError.ps1 | iex
@mklement0
mklement0 / Time-Command.ps1
Last active November 19, 2023 17:08
PowerShell function that times the execution of one or more commands, averaged over a specifiable number of runs.
<#
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/9e1f13978620b09ab2d15da5535d1b27/raw/Time-Command.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