How to download last camera record via PowerShell from UniFi NVR API with SSL

This guide explains how to download latest camera record available on UniFi NVR server via Powershell through the REST API with SSL self-signed certificate.

Requirements:

  • UniFi NVR server
  • User API key (user must have admin role)
  • PowerShell v3+
  • Modify first 3 lines of script to meet your environment requirements

Script:

Some notes:

  • Why was not used directly PS cmdlet Invoke-restmethod?
    • Because with this cmdlet is not possible to specify ignore self-signed certificate. Then you need to use HTTP request which is not secure for our purpose to download video over the network.
  • Why was not used PS cmdlet Invoke-WebRequest as well?
    • This cmdlet gives nice progress bar but cons is speed. First HTTP stream will be saved to buffer and then saved to disk. This is much slower than .NET Class WebClient.

With help of this script you can automate your video records – for example send records to the backup server in case some burglar will steal your NVR camera records. Or upload video to Slack channel…

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: