Skip to content

Instantly share code, notes, and snippets.

View joshooaj's full-sized avatar

Josh Hendricks joshooaj

View GitHub Profile
@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
@joshooaj
joshooaj / Rename-VmsHardwareAndDevices.ps1
Last active August 8, 2024 15:25
Bulk rename XProtect hardware and child devices
function Rename-VmsHardwareAndDevices {
<#
.SYNOPSIS
Renames hardware and all child devices using the default pattern.
.DESCRIPTION
This function renames the provided hardware(s) and all child devices. If a
value is provided for BaseName, the hardware will be renamed. The BaseName
can contain case-insensitive placeholders for any property available on a
Hardware object.
@joshooaj
joshooaj / Add-UniversalCamera.ps1
Last active July 9, 2024 21:24
Example function for adding an RTSP feed to XProtect using the universal camera driver
function Add-UniversalCamera {
<#
.SYNOPSIS
Adds a camera using one of the universal camera drivers.
.DESCRIPTION
The `Add-UniversalCamera` command adds a camera to a recording server using
one of the universal camera drivers. The camera address can be provided as
either an RTSP url complete with username and password, and path/query, or
the address can be provided as a traditional http/https url. If a path is
@joshooaj
joshooaj / New-Password.ps1
Last active July 1, 2024 20:03
Generate pseudo-random passwords
function New-Password {
<#
.SYNOPSIS
Generates a pseudo-random password.
.DESCRIPTION
This function generates a password with support for upper, and lower-case
characters, numbers, and symbols.
function Get-VmsFisheyeLens {
[CmdletBinding()]
param(
[Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'Camera')]
[VideoOS.Platform.ConfigurationItems.Camera]
$Camera,
[Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'Id')]
[Guid]
$Id
function Get-VmsCameraMotion {
<#
.SYNOPSIS
Gets the motion detection settings for one or more cameras.
.DESCRIPTION
The `Get-VmsCameraMotion` cmdlet gets the motion detection settings for one or more cameras. The MotionDetection
object for a camera can be accessed using $camera.MotionDetectionFolder.MotionDetections[0]. This command can be
considered a PowerShell-friendly shortcut for accessing these settings.
function Set-VmsDeviceStorage {
<#
.SYNOPSIS
Set the target storage configuration for a device in XProtect.
.DESCRIPTION
The `Set-VmsDeviceStorage` cmdlet sets the target storage configuration for a device in XProtect.
.PARAMETER Device
Tge one or more devices returned by the Get-VmsCamera, Get-Microphone, Get-Speaker, or Get-Metadata cmdlets.
@joshooaj
joshooaj / Compare-DHash.ps1
Last active March 14, 2024 16:15
Compare images using the dHash algorithm
function ConvertFrom-HexString {
[CmdletBinding()]
param (
[Parameter(Mandatory, Position = 0, ValueFromPipeline)]
[string]
$InputObject
)
process {
$bytes = [byte[]]::new($InputObject.Length / 2)