Skip to content

Instantly share code, notes, and snippets.

View aldrichtr's full-sized avatar

Tim Aldrich aldrichtr

View GitHub Profile
@aldrichtr
aldrichtr / psreadline_ideas.ps1
Created November 7, 2022 04:06
PSReadline Keyhandler ideas
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
}
oh-my-posh --init --shell pwsh --config "C:\Users\$env:userName\AppData\Local\Programs\oh-my-posh\themes\wylde.omp.json" | Invoke-Expression
@aldrichtr
aldrichtr / Example_XCCDF_Loop.ps1
Created November 9, 2022 18:33 — forked from rac3rx/Example_XCCDF_Loop.ps1
Looping through XCCDF XML with PowerShell
## set the path to the xml xccdf file.
$BenchMarkFilePath = '~\Documents\U_Windows_2012_and_2012_R2_MS_STIG_V2R6_Manual-xccdf.xml'
## load the content as XML
[xml]$Stigx = Get-Content -Path $BenchMarkFilePath -EA Stop
# start by parsing the xccdf security benchmark
if($Stigx){
$StigCollection = @()
# loop through the xccdf benchmark collecting data into an object collection
foreach ($rule in $StigX.Benchmark.Group.Rule){
@aldrichtr
aldrichtr / uia-sample.ps1
Created November 29, 2022 18:44 — forked from xiongjia/uia-sample.ps1
A simple sample for access the MS UIAutomation in PowerShell. #devsample #win
#REQUIRES -Version 3.0
# This is a simple sample for access the MS UIAutomation in PowerShell.
# In this sample:
# 1. Load the MS UIA via System.Reflection.Assembly
# 2. Launch the AUT ( calc.exe )
# 3. Find the AutomationElement via the AUT Process Id
# 4. Find buttons via 'ClassName' and 'Name' property
# 5. Click the '1', '+', '1', '=' buttons.
# At last, we will get '2' in the result of calc App.
@aldrichtr
aldrichtr / .gitconfig
Created November 29, 2022 18:46 — forked from xiongjia/.gitconfig
Some useful Git aliases that I use every day #conf #git
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
@aldrichtr
aldrichtr / connect.ps1
Created November 29, 2022 18:58 — forked from codebykyle/connect.ps1
Windows Terminal Split Pane Powershell Script - v2
using namespace System.Collections.Generic
# Encapsulate an arbitrary command
class PaneCommand {
[string]$Command
PaneCommand() {
$this.Command = "";
}
@aldrichtr
aldrichtr / DisplayFonts.ps1
Created November 29, 2022 20:07 — forked from matthewjberger/DisplayFonts.ps1
PowerShell Font Listing
# From https://technet.microsoft.com/en-us/library/ff730944.aspx
# This will open an internet explorer window that will display all installed windows font names in their corresponding font.
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$objFonts = New-Object System.Drawing.Text.InstalledFontCollection
$colFonts = $objFonts.Families
$objIE = New-Object -com "InternetExplorer.Application"
$objIE.Navigate("about:blank")
$objIE.ToolBar = 0
@aldrichtr
aldrichtr / PSStyleFileInfoTools.ps1
Created December 19, 2022 16:31 — forked from jdhitsolutions/PSStyleFileInfoTools.ps1
A set of functions for exporting and importing FileInfo settings from $PSStyle in PowerShell 7.2.
#requires -version 7.2
<#
These commands can be used to export FileInfo settings from $PSStyle and
then import them in another session. You might use the import command in
your PowerShell profile script. The file must be a json file.
#>
Function Export-PSStyleFileInfo {
[cmdletbinding(SupportsShouldProcess)]
Param(
@aldrichtr
aldrichtr / CellFindingVisitor.cs
Created December 27, 2022 22:17 — forked from SQLvariant/CellFindingVisitor.cs
PowerShell AST visitor to break up a file by comments
using System;
using System.Collections.Generic;
using System.Management.Automation.Language;
public class ScriptExtent : IScriptExtent
{
private readonly IScriptPosition _start;
private readonly IScriptPosition _end;
@aldrichtr
aldrichtr / Alacritty.yml
Created February 13, 2023 02:54 — forked from SuperMatt/Alacritty.yml
Dark+ V2 Terminal Theme
primary:
background: '#181818'
foreground: '#C7C7C7'
normal:
black: '#000000'
red: '#CD3131'
green: '#0DBC79'
yellow: '#E5E510'
blue: '#2472C8'
magenta: '#BC3FBC'
@aldrichtr
aldrichtr / Replace-Tokens.ps1
Created February 23, 2023 23:39 — forked from niclaslindstedt/Replace-Tokens.ps1
PowerShell script to replace tokens in a file. Useful for DevOps when you have a template config file that you wish to insert real values into.
<#
.SYNOPSIS
Replace tokens in a file with values.
.DESCRIPTION
Finds tokens in a given file and replace them with values. It is best used to replace configuration values in a release pipeline.
.PARAMETER InputFile
The file containing the tokens.