Skip to content

Instantly share code, notes, and snippets.

View joshooaj's full-sized avatar

Josh Hendricks joshooaj

View GitHub Profile
@joshooaj
joshooaj / Get-VmsDeviceStatus.ps1
Created May 24, 2021 23:11
Calls the RecorderStatusService2 to retrieve device status including if the camera is started, recording, not licensed, in overflow, etc.
function Get-VmsDeviceStatus {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'All')]
[Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'SpecifiedDevices')]
[VideoOS.Platform.ConfigurationItems.RecordingServer]
$RecordingServer,
[Parameter(Mandatory, ParameterSetName = 'All')]
[ValidateSet('Camera', 'Microphone', 'Speaker', 'Metadata', 'InputEvent', 'Output', 'Hardware')]
@joshooaj
joshooaj / Export-GpsCoordinates.ps1
Last active June 17, 2021 15:30
Exports the GPS coordinates of all cameras from a Milestone XProtect VMS installation
# Make sure we have permission to execute ps1 files within the scope of this running process only
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned -Force -Confirm:$false
if ($null -eq (Get-Module -ListAvailable -Name MilestonePSTools)) {
# MilestonePSTools is not installed so let's take care of some prerequisits for using Install-Module to install it
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$nugetProvider = Get-PackageProvider -ListAvailable -Name NuGet -ErrorAction Ignore
if ($null -eq $nugetProvider -or $nugetProvider.Version -lt [version]'2.8.5.201') {
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
}
@joshooaj
joshooaj / CameraReportWithSnapshots.ps1
Created June 17, 2021 06:46
Add live snapshots to Get-CameraReport
function ConvertFrom-Snapshot {
<#
.SYNOPSIS
Converts from the output provided by Get-Snapshot to a [System.Drawing.Image] object.
.DESCRIPTION
Converts from the output provided by Get-Snapshot to a [System.Drawing.Image] object. Don't
forget to call Dispose() on Image when you're done with it!
.EXAMPLE
PS C:\> $image = $camera | Get-Snapshot -Live | ConvertFrom-Snapshot
Get's a live snapshot from $camera and converts it to a System.Drawing.Image object and saves it to $image
@joshooaj
joshooaj / Show-Camera.ps1
Last active March 14, 2024 18:17
Launches a Windows WPF UI providing live video and playback for one or more cameras using the Milestone Systems MIP SDK components.
function Show-Camera {
[CmdletBinding()]
param (
# Specifies the Id of the camera you wish to view. Omit this parameter and you can select a camera from an item selection dialog.
[Parameter(ValueFromPipelineByPropertyName)]
[guid[]]
$Id,
# Specifies the diagnostic overview level to show overlayed onto the image
[Parameter()]
@joshooaj
joshooaj / Find-ArchiveGaps.ps1
Created July 23, 2021 18:19
Provides a list of gaps between tables in a Milestone XProtect media database based on the archives_cache.xml content
function Find-ArchiveGaps {
[CmdletBinding()]
param (
# Specifies the path to the archives_cache file to analyze
[Parameter()]
[string]
$Path = ".\archives_cache.xml"
)
process {
@joshooaj
joshooaj / PtzExample.ps1
Last active September 3, 2021 01:01
An example of how to send PTZ commands using MilestonePSTools, complete with reusable functions. May move these into MilestonePSTools later on.
function Get-PtzAbsolutePosition {
[CmdletBinding()]
[OutputType([VideoOS.Platform.Messaging.PTZGetAbsoluteRequestData])]
param(
# Specifies the FQID of the PTZ camera. Tip: If you have a "Camera" object, you need a "CameraItem" object instead. Use Get-PlatformItem to get the *Item object for the associated camera. The FQID property can be found attached to this.
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[VideoOS.Platform.FQID]$Fqid
)
process {
@joshooaj
joshooaj / Get-RoleReport.ps1
Last active November 25, 2024 19:36
A draft of a function to generate a sort of audit of all roles and all devices the roles have access to.
function Get-RoleReport {
[CmdletBinding()]
param(
[Parameter()]
[switch]
$IncludeNoAccess
)
process {
$cameras = Get-VmsCamera
@joshooaj
joshooaj / ApplyStorageTemplate.ps1
Created September 10, 2021 20:59
An example of how you might define a Milestone XProtect storage configuration template and use it to create/update live & archive storage to match
# Prompts you to choose a Recording Server to apply the template to
$recordingServer = Get-RecordingServer | Out-GridView -OutputMode Single
if ($null -eq $recordingServer) {
throw 'No Recording Server was selected'
}
# The template definition
$storageTemplate = @{
Live = @{
Name = 'Primary'
@joshooaj
joshooaj / Set-VmsPort
Created September 16, 2021 00:03
Update HTTP and HTTPS ports for Milestone XProtect Management Server, Log Server, Event Server and Report Server
#Requires -RunAsAdministrator
#Requires -Modules IISAdministration, MilestonePSTools
function Get-VmsIISSite {
[CmdletBinding()]
[OutputType([Microsoft.Web.Administration.Site])]
param()
process {
$site = Get-IISSite | Where-Object { $_.Applications | Where-Object ApplicationPoolName -like VideoOS* }
@joshooaj
joshooaj / New-VmsLECertificate.ps1
Last active October 10, 2025 15:03
Automate Let's Encrypt certificate management for Milestone XProtect Mobile Server using Posh-ACME with Dynu DNS.
<#
.SYNOPSIS
Request and install a publicly signed certificate from Let's Encrypt for your Milestone XProtect Mobile Server.
.DESCRIPTION
This script is an all(most)-in-one tool to register a publicly signed certificate from Let's Encrypt
based on a DDNS domain name registered at Dynu.com. Before you run this script, please visit
Dynu.com, register, add a DDNS domain name to your account, and visit your Dynu.com control panel
to generate and take note of your OAuth2 ClientID and Secret.