This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions) | |
License: MIT | |
Author: Michael Klement <[email protected]> | |
DOWNLOAD and INSTANT DEFINITION OF THE FUNCTION: | |
irm https://gist.github.com/mklement0/82ed8e73bb1d17c5ff7b57d958db2872/raw/Touch-File.ps1 | iex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Prerequisites: PowerShell v3+ | |
License: MIT | |
Author: Michael Klement <[email protected]> | |
DOWNLOAD and DEFINITION OF THE FUNCTION: | |
irm https://gist.github.com/mklement0/f726dee9f0d3d444bf58cb81fda57884/raw/Enter-AdminPSSession.ps1 | iex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
A terminal-based implementation of Conway's Game of Life. | |
.DESCRIPTION | |
Conway's Game of Life is a zero-player game that simulates a cellular automaton. | |
See https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life for background. | |
The initial state can be seeded explicitly or, by default, randomly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Gets installed programs on Windows. | |
.DESCRIPTION | |
Gets installed programs (applications) on Windows, either via the registry or, optionally, | |
via the Get-Package cmdlet, optionally filtered by | |
display-name substrings. | |
NOTE: As of PowerShell, v7.2, -UsePackageManagement only works in Windows PowerShell | |
(with the PackageManagement module installed). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-WithEnvironment { | |
<# | |
.SYNOPSIS | |
Invokes commands with a temporarily modified environment. | |
.DESCRIPTION | |
Modifies environment variables temporarily based on a hashtable of values, | |
invokes the specified script block, then restores the previous environment. | |
.PARAMETER Environment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-SpecialFolder { | |
<# | |
.SYNOPSIS | |
Gets special (known) folders. | |
.DESCRIPTION | |
Gets items representing special folders (directories), i.e., | |
folders whose purpose is predefined by the operating system. | |
In a string context, each such item expands to the full, literal path it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-CsvSampleData { | |
<# | |
.SYNOPSIS | |
Generates CSV sample data. | |
.DESCRIPTION | |
Generates simple CSV sample data as either a single multiline string or | |
an array of lines. | |
For now, the data-row field values are simply constructed as: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-OpenFiles { | |
<# | |
.SYNOPSIS | |
Finds open files. | |
.DESCRIPTION | |
Finds files currently being held open by any process and reports them as | |
[System.IO.FileInfo] instances, as Get-ChildItem would. | |
In fact, this function supports all parameters that Get-ChildItem does and |