Skip to content

Instantly share code, notes, and snippets.

View thedavecarroll's full-sized avatar

Dave Carroll thedavecarroll

View GitHub Profile
thedavecarroll / Join-OxfordComma.ps1
Last active November 19, 2022 04:23
The Join-OxfordComma command can provide you a comma separated list using the Oxford comma and either 'and' or 'or'.
View Join-OxfordComma.ps1
function Join-OxfordComma {
thedavecarroll / cibuild
Last active September 9, 2022 05:29
Recent Changes to the Site -
View cibuild
#!/usr/bin/env bash
set -e # halt script on error
echo "------------------------------------------------------------------------------------------------------------------------"
if [ "$TRAVIS_PULL_REQUEST" != "false" -a "$TRAVIS_BRANCH" == "comments" ]; then
echo "Building site for pull request for $TRAVIS_BRANCH..."
thedavecarroll / Add-TimeSpan.sp1
Created August 10, 2022 08:11
Simple function to add timespan
View Add-TimeSpan.sp1
function Add-TimeSpan {
[datetime]$Timestamp = (Get-Date),
thedavecarroll /
Last active March 30, 2022 15:24
Python Exception Logger and Boto3 Client
import boto3
from mylogger import logger,log_exception
def create_session(profile_name='default'):'Creating new boto3 session with profile {profile_name}')
return boto3.session.Session(profile_name=profile_name)
raise Exception( log_exception() )
View Get-PSFollowFridayTweetText.ps1
function Split-Array {
param (
[Parameter(Mandatory, ValueFromPipeline)]
[String[]] $InputObject
[ValidateRange(1, [int]::MaxValue)]
[int] $Size = 10
begin { $items = New-Object System.Collections.Generic.List[object] }
thedavecarroll / Get-ErrorCategory.ps1
Last active May 29, 2021 12:59
Twitter API Error Mapping
View Get-ErrorCategory.ps1
function Get-ErrorCategory {
[CmdletBinding(DefaultParameterSetName = 'APIV1.1')]
[Parameter(Mandatory, ParameterSetName = 'APIV1.1')]
[Parameter(Mandatory, ParameterSetName = 'APIV1.1')]
[Parameter(Mandatory, ParameterSetName = 'APIV2')]
thedavecarroll / Invoke-DiceRoll.ps1
Last active April 27, 2021 21:09
Simple Dice Roller, a la D&D
View Invoke-DiceRoll.ps1
function Invoke-DiceRoll {
ErrorMessage='Valid die types are d4,d6,d8,d10,d12,d20,d30,d100 rolled beteen 1 and 20 times. Your input was {0}. Please try again.'
[string]$Roll = '2d6',
thedavecarroll / PSChangeLogTools .psm1
Last active April 1, 2021 04:40
PSChangeLogTools script module which uses local git log, GitHub release, and GitHub issues to generate changelog updates
View PSChangeLogTools .psm1
#Requires -Module PowerShellforGitHub
#Requires -Version 5.1
# GitLog Class
# class definition created by ConvertTo-ClassDefinition at 3/31/2021 9:47:01 PM for object type PSCustomObject
class PSGitLog {
thedavecarroll / 1-Intermediate.ps1
Last active February 16, 2021 00:27
Another PowerShell Math Challenge - IronScripter Challenge - 2021-02-09 (Intermediate Only)
View 1-Intermediate.ps1
#requires -Version 7
function Get-SumTotal {
[Parameter(Mandatory,Position = 0,ValueFromPipeline)]
[ValidatePattern('^\d{1,10}$', ErrorMessage = '"{0}" does not match only numbers 0-9 with a maximum of 10.')]
#[ValidateScript({ if ($_ -notmatch '^\d{1,10}$') { throw ('{0}"{1}" does not match only numbers 0-9 with a maximum of 10.' -f [System.Environment]::NewLine,$_) } else { $true }})]
thedavecarroll / SearchADDnsRecord.psm1
Last active January 4, 2022 17:01
This simple PowerShell script module uses a custom class and Get-ADObject to search an Active Directory-integrated DNS Zone by name or partial name.
View SearchADDnsRecord.psm1
#Requires -Version 5.1
#Requires -Module ActiveDirectory
$script:ADRootDSE = Get-ADRootDSE
class ADDnsNode {
# AD Object Properties