Skip to content

Instantly share code, notes, and snippets.

View joshooaj's full-sized avatar

Josh Hendricks joshooaj

View GitHub Profile
@joshooaj
joshooaj / Export-RawVideo.ps1
Last active March 13, 2026 23:18
Save raw video data from an XProtect VMS to disk
#requires -Modules MilestonePSTools
<#
.SYNOPSIS
Exports raw video data from a camera on a Milestone XProtect VMS to a file.
.DESCRIPTION
Retrieves recorded video frames from a Milestone XProtect recording server
using the RawVideoSource API and writes the raw compressed frame data to a
file. By default, the 32-byte VMS GenericByteData headers are stripped,
@joshooaj
joshooaj / ProcessWatcher.ps1
Created March 11, 2026 23:43
Watch for new processes and write information about them to the terminal
# This just writes text to the terminal with Write-Host and isn't useful for long-term monitoring or logging or automation
$job = Register-CimIndicationEvent -Query "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'" -SourceIdentifier ProcessWatcher -Action {
param($sender, $e)
$p = $e.NewEvent.TargetInstance
Write-Host "`n---------`n"
Write-Host "Process: $($p.Name)"
Write-Host "ProcessId: $($p.ProcessId)"
Write-Host "Path: $($p.Path)"
Write-Host "CommandLine:"
@joshooaj
joshooaj / Rename-MediaDBTables.ps1
Created February 27, 2026 02:58
Rename XProtect media database tables by replacing the old device id with a new id in folder and config.xml files.
<#
.SYNOPSIS
Replace an old device ID with a new ID in a media database folder
.DESCRIPTION
If you have old XProtect recordings that you want to be able to playback in
XProtect, but the old recordings were made under a different device ID than
your cameras have now, you MIGHT be able to use this script to replace the
old device ID with the new device ID.
Before using this, you should have a secure backup of the recordings you want
@joshooaj
joshooaj / DllDirectoryManager.psm1
Last active February 7, 2026 20:24
Easily call the SetDllDirectory Win32 API function from PowerShell
function addDllDirectoryManager {
$csharp = @'
using System;
using System.Text;
using System.Runtime.InteropServices;
public static class DllDirectoryManager
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetDllDirectory(string lpPathName);
@joshooaj
joshooaj / PSMouseControl.psm1
Last active January 17, 2026 23:38
A little PowerShell module for moving, clicking, and scrolling the mouse on Windows
$typeDef = @'
using System;
using System.Runtime.InteropServices;
using System.Threading;
namespace PSMouseControl
{
struct FIXED
{
public short fract;
@joshooaj
joshooaj / extended-camera-report.ps1
Created January 16, 2026 17:29
Extend the output of Get-VmsCameraReport with Axis Zipstream properties
Get-VmsCameraReport | ForEach-Object {
$row = $_
$camera = Get-VmsCamera -Id $row.Id
$stream = $camera | Get-VmsCameraStream -RecordingTrack Primary
$settings = 'ZFpsMode', 'ZGopLength', 'ZGopMode', 'ZStrength'
foreach ($setting in $settings) {
$splat = @{
MemberType = 'NoteProperty'
Name = $setting
Value = $stream.Settings.$setting
@joshooaj
joshooaj / New-VmsCarouselView.ps1
Last active January 11, 2026 03:00
Create carousel views for XProtect Smart Client
#Requires -Modules MilestonePSTools
<#
.SYNOPSIS
Creates a Smart Client view containing one or more camera carousel view items.
.DESCRIPTION
The New-VmsCarouselView script automates the creation of Milestone XProtect Smart
Client views containing carousel view items. A carousel view item automatically
rotates through a list of cameras at a specified interval, displaying each camera
for a set duration before moving to the next.
@joshooaj
joshooaj / procdump.ps1
Last active January 8, 2026 22:39
PowerShell script to schedule and create memory dumps using procdump
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Creates memory dumps using procdump.exe with automatic compression and retention management.
.DESCRIPTION
This script captures memory dumps of a specified process using Sysinternals procdump.exe,
compresses them into ZIP archives, and manages retention by keeping only the most recent dumps.
@joshooaj
joshooaj / PSBeets.psm1
Created September 4, 2025 19:20
A mix of PowerShell functions for working with my music library. Work in progress...
$script:itemFields = @'
acoustid_fingerprint
acoustid_id
added
album
album_id
albumartist
albumartist_credit
albumartist_sort
albumdisambig
@joshooaj
joshooaj / generate-decade-playlists.ps1
Created September 4, 2025 19:09
Generate "Best Of Decade" smart playlists for Navidrome
param(
[Parameter()]
[int]
$MinYear = 1960,
[Parameter()]
[int]
$MaxYear = 2020,
[Parameter()]