Skip to content

Instantly share code, notes, and snippets.

View joshooaj's full-sized avatar

Josh Hendricks joshooaj

View GitHub Profile
@joshooaj
joshooaj / convert.ps1
Last active January 22, 2025 23:08
Convert all video in one or more XProtect database to mkv files
#require -Modules MilestonePSTools, MilestoneSystems.PowerShell.MediaDB
param(
# Specifies the path to a folder containing one or more XProtect media database folders.
[Parameter()]
[string]
$Source,
# Specifies the path to a folder where MKV files will be saved.
[Parameter()]
[string]
@joshooaj
joshooaj / parallel-exports.ps1
Created January 13, 2025 20:35
Export recording sequences in parallel
#requires -Modules Microsoft.PowerShell.ThreadJob
<#
This is an example of how you could parallelize exports. You _probably_ wouldn't do this specific thing in practice
but it was an easy proof of concept on a small system.
The following script will get all enabled cameras, and then get all recording sequences for todays date, and then
using the Start-ThreadJob command, it will run each export in a separate job, saving each recording sequence found
on each enabled camera to it's own MKV file in the C:\temp directory.
#>
@joshooaj
joshooaj / New-RandomPass.ps1
Last active December 10, 2024 23:31 — forked from steviecoaster/New-RandomPass.ps1
Cross platform password generator
function New-RandomPass {
<#
.Synopsis
Generates and returns a suitably secure password
.EXAMPLE
New-RandomPass
Returns a random password as a SecureString object
.EXAMPLE
@joshooaj
joshooaj / ParsePng.ps1
Created December 3, 2024 21:30
Parse PNG files into their individual chunks
function ParsePng {
[CmdletBinding()]
param(
[Parameter(Mandatory, Position = 0)]
[string]
$Path
)
process {
try {
@joshooaj
joshooaj / New-QueryString.ps1
Last active November 25, 2024 22:52 — forked from steviecoaster/New-QueryString.ps1
Creates a querystring to use with an API call
function New-QueryString {
<#
.SYNOPSIS
Turn a hashtable into a URI querystring
.DESCRIPTION
Turn a hashtable into a URI querystring
.PARAMETER QueryParameter
The hashtable to transform
@joshooaj
joshooaj / Send-VmsDriverCommand.ps1
Last active November 26, 2024 00:03
Send custom driver commands to XProtect
function Send-VmsDriverCommand {
<#
.SYNOPSIS
Sends a custom HTTP request or command to a device added to an XProtect VMS.
.PARAMETER Camera
Specifies the camera to which the driver command should be sent.
.PARAMETER Fqid
Specifies the FQID associated with the destination device. Try `Get-VmsVideoOSItem` to retrieve an item, and then
@joshooaj
joshooaj / Show-DateTimePicker.ps1
Last active October 1, 2024 20:48
Simple datetime picker ui implementation for Windows PowerShell
function Show-DateTimePicker {
[CmdletBinding()]
param(
[Parameter()]
[string]
$Title = 'Show-DateTimePicker',
[Parameter()]
[DateTimeKind]
$Kind = [DateTimeKind]::Local
@joshooaj
joshooaj / Get-CamerasThatArentInAView.ps1
Last active September 12, 2024 23:14
Discover cameras that are NOT in a view
function Get-CamerasThatArentInAView {
[CmdletBinding()]
param ()
process {
$camerasInViews = @{}
$publicViewGroups = Get-VmsViewGroup | Where-Object Name -ne 'Private'
$views = $publicViewGroups | Get-VmsViewGroup -Recurse | Get-VmsView
foreach ($view in $views) {
@joshooaj
joshooaj / Measure-Distance.ps1
Last active August 30, 2024 18:23
Measure the distance between two coordinates
function ConvertToGeoCoordinate ([string]$coordinate) {
Add-Type -AssemblyName System.Device
$lat, $lon = $Coordinate -split ',' | ForEach-Object {
[double]$_.Trim()
}
[device.location.geocoordinate]::new($lat, $lon)
}
function Measure-Distance {
[CmdletBinding()]
@joshooaj
joshooaj / MipItemCompleter.cs
Created July 25, 2024 23:25
Generic MIP Item Argument Completer for PowerShell
using MilestonePSTools.Connection;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Language;
using System.Text.RegularExpressions;
using VideoOS.ConfigurationApi.ClientService;
namespace MilestonePSTools.Utility