Skip to content

Instantly share code, notes, and snippets.

View griffeth-barker's full-sized avatar

Griffeth Barker griffeth-barker

View GitHub Profile
@griffeth-barker
griffeth-barker / New-ShortenedUri.ps1
Last active August 2, 2025 15:20
Generate a shortened Uri using TinyURL
function New-ShortenedUri {
<#
.SYNOPSIS
Genereates a shortened Uri.
.DESCRIPTION
Genereates a shorted Uri based on the provided Uri using the TinyUrl service.
.PARAMETER Uri
A mandatory Uri to be shortened.
.PARAMETER CopyToClipboard
An optional switch that copies the shortened Uri to the clipboard if specified.
@griffeth-barker
griffeth-barker / unixTimestampFunctions.ps1
Created July 11, 2025 16:56
Converting between Unix timestamps and DateTime objects
function ConvertFrom-UnixTimestamp {
<#
.SYNOPSIS
Converts a Unix timestamp to a DateTime object.
.DESCRIPTION
Converts a Unix timestamp to a DateTime object.
.PARAMETER Milliseconds
The Unix timestamp to convert.
.INPUTS
String
@griffeth-barker
griffeth-barker / New-RandomMACAddress.ps1
Last active June 16, 2025 21:45
Generate a random MAC address, or a MAC address using a vendor's prefix, based on the IEEE's OUI listing.
function New-RandomMACAddress {
<#
.SYNOPSIS
Generates a MAC address.
.DESCRIPTION
This function generates a random MAC address. If specified, the MAC address will be generated using the vendor prefix (OUI) for
the partial name of the vendor provided, if found in the IEEE OUI listing. See https://standards-oui.ieee.org/cid/cid.csv for the
full OUI listing.
The OUI listing is downloaded to the system's temp directory from the internet. If the OUI listing already exists, it will not be
@griffeth-barker
griffeth-barker / Export-DistributionGroupInfo.ps1
Created June 4, 2025 17:47
Export a distribution group's information from Exchange Online
function Export-DistributionGroupInfo {
<#
.SYNOPSIS
This function exports the information for an Exchange Online distribution group.
.DESCRIPTION
This function takes in an array of distribution group PrimarySmtpAddresses. Each group is looked up and their information
is condensed to a single .csv file which is exported to your Downloads directory.
.PARAMETER Groups
@griffeth-barker
griffeth-barker / Import-ModuleFromGitx.ps1
Last active June 4, 2025 19:00
Import a PowerShell module directly from GitHub/GitLab without having to install it.
function Import-ModuleFromGitx {
<#
.SYNOPSIS
Imports a PowerShell module from a GitHub repository.
.DESCRIPTION
This function lets you import a PowerShell module directly from a GitHub repository without needing to install the module.
The module is downloaded from the specified GitHub repository URI, extracted, and imported into your current PowerShell session.
.PARAMETER Uri
@griffeth-barker
griffeth-barker / colorfulPrompt.ps1
Created June 1, 2025 17:24
Colorful PowerShell Prompt
<#
.SYNOPSIS
A colorful PowerShell prompt.
.DESCRIPTION
This function replaces your default PowerShell prompt with a colorful one.
The format of the prompt looks like this: `username@hostname:[C:\Users\griff.systems\Documents]>`
Each new command line gets a random console color from the available default console colors.
You can add this to your `$profile` to use the custom prompt.
@griffeth-barker
griffeth-barker / Uninstall-WindowsCopilot.ps1
Last active June 1, 2025 17:31
Uninstall Windows Copilot
function Uninstall-WindowsCopilot {
<#
.SYNOPSIS
Uninstalls Windows Copilot.
.DESCRIPTION
This function uninstalls the new Windows Copilot package.
.PARAMETER Scope
@griffeth-barker
griffeth-barker / Update-GitRepositories.ps1
Last active June 1, 2025 14:23
Pull and rebase updates for all Git repositories in a base directory. This can optionally be scheduled to run via a cron job or Windows Task Scheduler.
function Update-GitRepositories {
<#
.SYNOPSIS
Pulls updates for Git repositories.
.DESCRIPTION
This function invokes `git pull --rebase` on all Git repositories found in the specified base directory.
.PARAMETER BaseDirectory
@griffeth-barker
griffeth-barker / Invoke-DiceRoll.ps1
Last active June 1, 2025 14:18
Ready to roll dice in PowerShell? Download the Invoke-DiceRoll function! It supports a parameter for each of the most common polyhedral dice (d4, d6, d8, d10, d12, 420), where you can provide an integer representing the quantity of that type of die you'd like to roll. You can roll multiple types of dice at the same time!
function Invoke-DiceRoll {
<#
.SYNOPSIS
Rolls one or more dice of standard types (d4, d6, d8, d10, d12, d20) and returns the results.
.DESCRIPTION
The Invoke-DiceRoll function simulates rolling dice commonly used in tabletop games.
You can specify the number of each die type to roll (d4, d6, d8, d10, d12, d20).
.PARAMETER D4
The number of 4-sided dice (d4) to roll.