Set the PowerShell Window Title
$host.ui.RawUI.WindowTitle = "My Useful Script is Running " + $MyInvocation.MyCommand.Path;
Source:
https://www.tutorialspoint.com/how-to-get-the-path-of-the-currently-executing-script-in-powershell
Shell Command to List Path To Files
If you need a list of full paths to the files in the current directory use the readlink command:
readlink -r *
Shell Command To Recursively Find Most Recently Modified Files
find . -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- | head
Adapted from https://stackoverflow.com/questions/5566310/how-to-recursively-find-and-list-the-latest-modified-files-in-a-directory-with-s
GIST – Extract utm_medium from Apache Log
Don’t include the known value ’email’ in the results.
cat access.log | grep utm_medium | grep -v "utm_medium=email" | sed -n 's/.*utm_medium=\([^&]*\).*/\1/p'
GIST – Filter Windows Eventlog Messages By Log, Event ID, and Message
$startDate = (Get-Date -Year 2023 -Month 8 -Day 1).Date # .Date makes it midnight $endDate = (Get-Date -Year 2023 -Month 8 -Day 20).Date
Get-WinEvent -FilterHashtable @{logname = 'Application'; id = 4} -MaxEvents 25 | Where-Object { $_.Timecreated -ge $startDate -and $_.Timecreated -lt $endDate } | where message -match "Message to find" | Format-Table -wrap