Skip to content

Instantly share code, notes, and snippets.

View jkavanagh58's full-sized avatar

John J Kavanagh jkavanagh58

View GitHub Profile
@jkavanagh58
jkavanagh58 / update-wtsettingsgit.ps1
Created August 8, 2021 20:44
Copy Windows Terminal settings file for sharing/backup
[CmdletBinding()]
Param (
[parameter(Mandatory = $False, ValueFromPipeline = $True,
HelpMessage = "wt settings file")]
[System.IO.FileInfo]$wtSettings = 'C:\Users\johnk\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json',
[parameter(Mandatory = $False, ValueFromPipeline = $False,
HelpMessage = "Name of file for update")]
[System.String]$wtRepoFile = "wt_settings_jkav.json",
[parameter(Mandatory = $False, ValueFromPipeline = $True,
HelpMessage = "Path to local clone")]
@jkavanagh58
jkavanagh58 / coreprofile.ps1
Last active August 8, 2021 14:31
ps core profile
"Loading system functions"
. C:\etc\scripts\system-functions.ps1
"Welcome to PowerShell on {0}" -f $psversiontable.Platform
Function test-onlineprof {
[CmdletBinding()]
Param (
[parameter(Mandatory = $True, ValueFromPipeline = $False,
HelpMessage = "Url to profile gist")]
[System.String]$profOnline = 'https://gist.github.com/jkavanagh58/5e28bcb7475d714f564785bd15e5a120'
)
@jkavanagh58
jkavanagh58 / powershell.json
Created November 12, 2019 14:18
Current VSCode PowerShell Snippet file
{
"Day of Week Validated Parameter": {
"prefix": "DOWParam",
"body": [
"[Parameter(Mandatory = $$true,\r",
"\tValueFromPipeline = $$true,\r",
"\tHelpMessage = \"${1:Enter Help Message Here}\")]\r",
"[ValidateSet('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday')]\r",
"[System.String]$${2:parametername}\r"
],
@jkavanagh58
jkavanagh58 / collarray snippet
Last active October 31, 2019 14:05
VSCode PowerShell Snippet for using System.Collections.ArrayList to create an Array
"Array List using Collection": {
"prefix": "collarray",
"body": [
"# Create New Array\r",
"$${1:arrayName} = [System.Collections.ArrayList]@()\r",
"# Add items to array\r",
"$${1}.Add(\"${2:ItemValue}\") | Out-Null"
],
"description": "Form Array using .Net Collection"
}
@jkavanagh58
jkavanagh58 / Function CBH
Created October 1, 2019 15:15
VSCode Snippet - PowerShell CBH for Functions
"Function CBH": {
"prefix": "PSFuncHelp",
"body": [
"<#\r",
".SYNOPSIS\r",
"\tShort description",
".DESCRIPTION\r",
"\tLong description",
".PARAMETER Path\r",
"\tSpecifies a path to one or more locations.",
<#
.SYNOPSIS
Clean up PowerShell Installed Modules
.DESCRIPTION
Examine installed modules and determine versions that can be removed from installation folder.
.PARAMETER modInstalled
Collection of currently installed modules installed via PowerShellGet
.EXAMPLE
PS> ./uninstall-module-history.ps1
Example of how to use this script
Find-Module -Tag PSEdtion_Desktop, PSEdition_Code
Find-Module -Tag PSEdtion_Desktop, PSEdition_Code
@jkavanagh58
jkavanagh58 / powershell.json
Last active September 10, 2018 15:03
Customized PowerShell snippet file for Visual Studio Code
{
"PS Custom Object": {
"prefix": "customobj",
"body": [
"$$obj = [pscustomobject]@{",
"\t$FieldName = $FieldValue\r",
"}"
],
"description": "Skeleton for adding a PowerShell Custom Object"
},
#Requires -Modules ImportExcel
$xlsxPath = "C:\Users\vndtekjxk\OneDrive - Wegmans Food Markets, Inc\Documents\SRM"
$xlsxName = "SRM1.xlsx"
$xlsxFile = Join-Path $xlsxPath -ChildPath $xlsxName
If (Test-Path $xlsxFile) {
$dataSet = Import-Excel -Path $xlsxFile -WorksheetName Sheet1 -DataOnly
$dataSet | Select-Object -Property Group -Unique | sort-object -Property Group
}