Skip to content

Instantly share code, notes, and snippets.

@marckassay
marckassay / Get-ModuleSynopsis.ps1
Last active August 26, 2017 18:39
Get-ModuleSynopsis - Lists all available functions for a module, with the synopsis of those functions.
<#
.SYNOPSIS
Lists all available functions for a module, with the synopsis of the functions.
.DESCRIPTION
Lists all available functions of a module using Get-Command and Get-Help.
.PARAMETERS
Name <String> The name of the module installed.
@marckassay
marckassay / Get-Bytes.ps1
Last active January 21, 2018 23:20
A PowerShell function to output a file's bytes in decimal and/or binary notation
<#
.SYNOPSIS
Outputs a file's bytes in decimal and/or binary notation
.DESCRIPTION
Initially created to compare files prior to UTF encoding.
.PARAMETER Path
Path to file.
@marckassay
marckassay / Get-MergedPath.ps1
Last active January 24, 2018 14:28
Returns a valid path from a parent of one of its childs which overlaps that parent.
<#
.SYNOPSIS
Returns a valid path from a parent of one of its children which overlaps that parent's path.
.DESCRIPTION
In set-theory this will be considered a relative complement. That is the directories
in ChildPath that are not in Path.
A diagram to illustrate what is mentioned above:
A = C:\Windows\diagnostics\system
@marckassay
marckassay / Get-ParentItem.ps1
Last active January 24, 2018 15:16
Similarly to Get-ChildItem, this function can recurse the -Path parameter parent or parents for a file or folder
<#
.SYNOPSIS
Similarly to Get-ChildItem, this function can recurse the -Path parameter parent or parents
for a file or folder
.DESCRIPTION
Long description
.PARAMETER Path
The path to start
@marckassay
marckassay / gist:45f186d0f51a1d58621a0cf4acb10457
Last active February 26, 2018 13:17
Notes on: Install Jekyll (and Ruby) on Windows for GitHub pages
1. Install Ruby that is greater or equal to 2.4.0, this will install "DevKit" that developers refer to:
	https://rubyinstaller.org/downloads/

	*** If you come across any issues and search online, be mindful that when recommended to '$ ruby dk.rb init' they are referring to an older version of Ruby than 2.4.0 ***

2. As of this writing there is bug in ridk ( https://github.com/oneclick/rubyinstaller2/issues/101 ).  So after Ruby install, restart CLI and execute:
	$ ridk exec pacman -Syu --needed --noconfirm --ask 20
	$ ridk install 2 3

3. Unable to run Jekyll following GitHub instructions ( bundle exec jekyll _3.3.0_ new NEW-JEKYLL-SITE-REPOSITORY-NAME ), so use the following instead:
@marckassay
marckassay / Update-ModuleManifest.Tests.ps1
Created June 26, 2018 14:11
Update-ModuleManifest reverts back to previous key value after subsequent calls
Describe "Test Update-ModuleManifest" {
BeforeAll {
$ManifestContentString = @"
@{
# Script module or binary module file associated with this manifest.
RootModule = 'MockModule.psm1'
# Version number of this module.
ModuleVersion = '0.0.1'
@marckassay
marckassay / Get-PublicIPv4Log.ps1
Created July 12, 2018 00:46
Calls a REST endpoint to retrieve your IPv4 address along with other information on about ISP and geo-location
<#
.SYNOPSIS
Calls a REST endpoint to retrieve your IPv4 address along with other information about ISP and geo-location
.DESCRIPTION
Long description
.PARAMETER Uri
The REST service providing the ISP information from your request. Defaults to 'http://ipinfo.io/json'
@marckassay
marckassay / yarnissue6560.ps1
Created November 3, 2018 11:29
Demonstrates when 'yarn unlinks', symlink in user home directory still exists. See issue here: https://github.com/yarnpkg/yarn/issues/6560
$PackageName = "yarn-example-no$(Get-Random -Maximum 1000)"
New-Item -Value @"
{
"name": "$PackageName",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true
}
"@ -Name package.json -Path $PackageName -Force | Out-Null
@marckassay
marckassay / symlink_resolver.cmd
Last active November 26, 2018 22:40
Batch script that resolves its symlink's value
@marckassay
marckassay / Set-AssociateFileExtensions.ps1
Last active July 18, 2024 13:32
This sample provides a script for IT pro or windows customers to quickly batch associated file extensions with application on Windows by PowerShell.
<#
.SYNOPSIS
"This sample provides a script for IT pro or windows customers to quickly batch associated file extensions with application
on Windows by PowerShell."
.DESCRIPTION
"The most efficient way to change file associations is by selecting a default program. This tells Windows that you want a
certain program to be associated with all the file types it can handle. IT pro or windows customers want to have some kinds
of batch method to automatically associate a selection of file extensions. This sample script will help to quickly batch
the associated file extensions with application on Windows."