Skip to content

Installing MilestonePSTools

Quick Install

There are multiple ways to install MilestonePSTools. The quickest method is to copy & paste the following line into a Windows PowerShell prompt on the computer where you want to use it.

Quick Install
Set-ExecutionPolicy RemoteSigned -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-Expression (Invoke-RestMethod 'https://www.milestonepstools.com/install.ps1')

Tip

MilestonePSTools does not need to be installed on the Milestone XProtect Management Server. Nearly every command in the module is designed to connect to your VMS the same way XProtect Smart Client and Management Client do.

Requirements

  • Supports all Milestone XProtect Advanced VMS editions, including XProtect Essential+.
  • Some features in MilestonePSTools rely on specific VMS editions. For example, creating evidence locks requires that you run XProtect Corporate.
  • Requires XProtect Management Server version 2014 or greater.
  • Some functionality in MilestonePSTools will require newer software versions.
  • Supports Windows PowerShell 5.1 (Desktop edition) with .NET Framework 4.7 or later
  • Requires FullLanguage language mode

Tip

  • To check your PowerShell version, open PowerShell and type $PSVersionTable. The PSVersion value is your PowerShell version.
  • If you have an earlier version of PowerShell, you may need to install Windows Management Framework 5.1.
  • If you have a newer version of PowerShell, that's okay! PowerShell 5.1 can operate side by side with newer versions of PowerShell.

Install for all users

This script will prepare your PowerShell environment by updating certain components used to support installation of modules from Microsoft's PowerShell Gallery. It will then install the module for all users on the local system. This is the same script used by the one-line command at the top of this page.

install.ps1
$script = {
    Write-Host 'Setting SecurityProtocol to TLS 1.2 and greater' -ForegroundColor Green
    $protocol = [Net.SecurityProtocolType]::SystemDefault
    [enum]::GetNames([Net.SecurityProtocolType]) | Where-Object {
        # Match any TLS version greater than 1.1
            ($_ -match 'Tls(\d)(\d+)?') -and ([version]("$($Matches[1]).$([int]$Matches[2])")) -gt 1.1
    } | Foreach-Object { $protocol = $protocol -bor [Net.SecurityProtocolType]::$_ }
    [Net.ServicePointManager]::SecurityProtocol = $protocol


    $policy = Get-ExecutionPolicy
    if ((Get-ExecutionPolicy) -notin 'RemoteSigned', 'Unrestricted') {
        Write-Host "Changing Execution Policy from $policy to RemoteSigned" -ForegroundColor Green
        Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser -Confirm:$false -Force -ErrorAction SilentlyContinue
        Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Confirm:$false -Force -ErrorAction SilentlyContinue
    }


    if ($null -eq (Get-PackageSource -Name NuGet -ErrorAction Ignore)) {
        Write-Host 'Registering NuGet package source' -ForegroundColor Green
        $null = Register-PackageSource -Name NuGet -Location https://www.nuget.org/api/v2 -ProviderName NuGet -Trusted -Force
    }

    $nugetProvider = Get-PackageProvider -Name NuGet -ErrorAction Ignore
    $requiredVersion = [Microsoft.PackageManagement.Internal.Utility.Versions.FourPartVersion]::Parse('2.8.5.201')
    if ($null -eq $nugetProvider -or $nugetProvider.Version -lt $requiredVersion) {
        Write-Host 'Installing NuGet package provider' -ForegroundColor Green
        $null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
    }

    if ($null -eq (Get-Module -ListAvailable PowerShellGet | Where-Object Version -ge 2.2.5)) {
        Write-Host 'Installing PowerShellGet 2.2.5 or greater' -ForegroundColor Green
        $null = Install-Module PowerShellGet -MinimumVersion 2.2.5 -Scope AllUsers -AllowClobber -Force -ErrorAction Stop
    }

    Write-Host 'Installing MilestonePSTools' -ForegroundColor Green
    Install-Module MilestonePSTools -Scope AllUsers -Force -ErrorAction Stop -SkipPublisherCheck -AllowClobber

}
$InformationPreference = 'Continue'
$encodedCommand = [Convert]::ToBase64String([text.encoding]::Unicode.GetBytes($script))
Start-Process -FilePath powershell.exe -ArgumentList "-encodedCommand $encodedCommand" -Verb RunAs -Wait
Write-Host "$(Get-Module -ListAvailable MilestonePSTools | Out-String)"

Warning

Installing a PowerShell module for all users requires Administrative privileges. Once installed, it is generally recommended to use a non-privileged PowerShell terminal unless the task you're performing requires elevation.

Install for the current user

This script is similar to the all-users script, except it installs and updates components without requiring administrative privileges. This means that unless security policies prevent normal users from changing the execution policy in your environment, you can probably install MilestonePSTools without needing to "run as administrator". It also means the MilestonePSTools commands will only be available to your user account.

install-currentuser.ps1
Write-Host 'Setting SecurityProtocol to TLS 1.2 and greater' -ForegroundColor Green
$protocol = [Net.SecurityProtocolType]::SystemDefault
[enum]::GetNames([Net.SecurityProtocolType]) | Where-Object {
    # Match any TLS version greater than 1.1
            ($_ -match 'Tls(\d)(\d+)?') -and ([version]("$($Matches[1]).$([int]$Matches[2])")) -gt 1.1
} | Foreach-Object { $protocol = $protocol -bor [Net.SecurityProtocolType]::$_ }
[Net.ServicePointManager]::SecurityProtocol = $protocol

Write-Host 'Setting Execution Policy to RemoteSigned' -ForegroundColor Green
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false -Force -ErrorAction SilentlyContinue

if ($null -eq (Get-PackageSource -Name NuGet -ErrorAction Ignore)) {
    Write-Host 'Registering NuGet package source' -ForegroundColor Green
    $null = Register-PackageSource -Name NuGet -Location https://www.nuget.org/api/v2 -ProviderName NuGet -Trusted -Force
}

$nugetProvider = Get-PackageProvider -Name NuGet -ErrorAction Ignore
$requiredVersion = [Microsoft.PackageManagement.Internal.Utility.Versions.FourPartVersion]::Parse('2.8.5.201')
if ($null -eq $nugetProvider -or $nugetProvider.Version -lt $requiredVersion) {
    Write-Host 'Installing NuGet package provider' -ForegroundColor Green
    $null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
}

if ($null -eq (Get-Module -ListAvailable PowerShellGet | Where-Object Version -ge 2.2.5)) {
    Write-Host 'Installing PowerShellGet 2.2.5 or greater' -ForegroundColor Green
    $null = Install-Module PowerShellGet -MinimumVersion 2.2.5 -Scope CurrentUser -AllowClobber -Force -ErrorAction Stop
}

Write-Host 'Installing MilestonePSTools' -ForegroundColor Green
Install-Module MilestonePSTools -Scope CurrentUser -Force -ErrorAction Stop -SkipPublisherCheck -AllowClobber

Install manually

If your Milestone VMS is "air-gapped" or for any other reason you're unable to install a PowerShell module using the Install-Module cmdlet which downloads it directly from PowerShell Gallery, you can still install MilestonePSTools.

Step 1: Download the Nupkg files

What on earth is a nupkg file? For starters, you can pronounce it as "Nup-keg" which is fun! And it stands for "NuGet Package". Oh, and NuGet is the name of Microsoft's package manager introduced primarily for managing .NET application packages. In this case, "package" means one or more DLL files and some basic instructions for where they go. Back before ~2010, most .NET developers were manually copying around DLL files and adding references to them when needed. It made it very complicated to share reusable libraries. Now, with NuGet.org, you can reference a package by name, and automatically download/unpack/use that package.

To manually download MilestonePSTools, you'll need to download two files. The first is the MilestonePSTools "raw nupkg file", and the second is the MipSdkRedist nupkg. The MipSdkRedist module is the container used for the Milestone MIP SDK on which MilestonePSTools is based. Here are the links to the two PowerShell modules on PSGallery. Once there, click Manual Download under Installation Options and then click Download the raw nupkg file.

Step 2: Extract the contents

These nupkg files are actually ZIP files! If you add the .zip extension to the file, you can view/extract the contents like any other zip file. Here's what the contents look like for MilestonePSTools...

MilestonePSTools nupkg file contents screenshot

Before you extract the ZIP files, make sure to right-click on both files and open Properties. If you see a checkbox to "unblock" the files, you should do this before extracting them. Otherwise each individual extracted file will also be blocked.

Step 3: Copy to the destination

After you extract the files for the module, the best place to put them is in one of the locations PowerShell automatically looks for PowerShell modules. If you install the module for just you, then you should place the module in your Documents directory under Documents\WindowsPowerShell\Modules. The folder(s) may not already exist. If so, you should create them yourself.

Alternatively if you want to make the module(s) available to any user on the local machine you can place them in C:\Program Files\WindowsPowerShell\Modules.

Tip

To see where Windows PowerShell will look to auto-import modules in your environment, type

$env:PSModulePath -split ';'

The structure for the Modules folder is that the first level includes a folder matching the name of the module, and the subfolder contains one or more versions of that module where the name of the folder matches the exact version of the module as defined in the *.psd1 file at the root of the specific module's folder. In the example below, we have MilestonePSTools version 21.2.2, and inside that folder are the contents from the screenshot above such that MilestonePSTools.psd1 exists inside the folder named "21.1.451603".

Modules/
|---MilestonePSTools/
|   |---21.2.2/
|       |---MilestonePSTools.psd1
|---MipSdkRedist/
|   |---21.2.0/
|       |---MipSdkRedist.psd1

Once you have the modules extracted and placed in the right location, you should be able to run Import-Module MilestonePSTools and both MipSdkRedist and MilestonePSTools will be loaded into your PowerShell session. If you get an error message, check out this blog post to see if we've already shared some tips on how to deal with it!