A collection of sample scripts to bootstrap your Milestone XProtect VMS Management Adventure
Explore the samples »
Report Bug
·
Request Feature
This repository contains sample PowerShell scripts for managing and automating tasks related to Milestone XProtect VMS software using MilestonePSTools. It is intended to be a supplement to the built-in documentation available in many cmdlets within MilestonePSTools which you can access using Get-Help.
In order to make the most out of MilestonePSTools you will need at least some basic familiarity with PowerShell or other shells. It's possible to perform very basic actions in a few lines of PowerShell with limited experience. With a bit more experience and ambition, it's also possible to develop extensive and powerfull tools or entire modules to automate important business and maintenance tasks unique to your organization.
If you're new to PowerShell, there are a wide range of resources available to learn. One popular example is the Learn Windows PowerShell in a Month of Lunches series which, while last updated in 2014, is still a good resource for picking up the syntax and style.
MilestonePSTools is developed using the latest build of Milestone's MIP SDK. As such, it has the following prerequisits:
- Milestone XProtect VMS (XProtect Essential+, Express+, Professional+, Expert, or Corporate) 2014 or newer
- Windows Desktop/Server edition (not compatible with PowerShell Core)
- .NET Framework 4.7
- PowerShell 5.1 or newer. Use
$PSVersionTableto determine the PSVersion of your current PowerShell terminal
You can install MilestonePSTools on the computer where your Milestone VMS is installed, but that is not required. In fact, from a security standpoint it is best to avoid installing software on the same server as your VMS if it's not necessary. Just as the XProtect Smart Client and Management Client may be used from a networked PC, so too can MilestonePSTools be used from a remote system.
- Check PowerShell Execution Policy and consider switching to RemoteSigned if currently set to 'Restricted'
Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned1b. Microsoft have improved security on their PSGallery repository. If you install MilestonePSTools using the Install-Module cmdlet, you might need to run the following to ensure TLS 1.2 is used for communication with PSGallery. Otherwise you may see a variety of different possible error messages when attempting to run Install-Module.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck- Trust the PSGallery repository (optional)
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted- Install MilestonePSTools for your Windows profile
Install-Module MilestonePSTools -Scope CurrentUser- Connect with the current Windows user
Connect-ManagementServer -Server myvms -AcceptEula
- Connect with a Windows or Active Directory user
Connect-ManagementServer -Server myvms -Credential (Get-Credential) -AcceptEula
- Connect with a Milestone Basic User
Connect-ManagementServer -Server myvms -Credential (Get-Credential) -BasicUser -AcceptEula
# Slower but uses Configuration API so each object can be used to modify configuration
Get-Hardware | Where-Object Enabled | Get-Camera | Where-Object Enabled | Select Name
# Faster but provides limited access to camera properties and Items cannot be used to modify configuration
Get-PlatformItem -Kind (Get-Kind -List | ? DisplayName -eq Camera).Kind | Select Name-
Using Add-Hardware
# Select a Recording Server by name $recorder = Get-RecordingServer -Name Artemis # Add a StableFPS device (if the driver is installed) using the default hardware name $hardware1 = Add-Hardware -RecordingServer $recorder -Address http://192.168.1.101:1001 -UseDefaultCredentials -DriverId 5000 -GroupPath /StableFPS # Add a camera without specifying the driver, name it 'New Camera' and place it in a Camera Group named 'New Cameras' $hardware2 = Add-Hardware -RecordingServer $recorder -Name 'New Camera' -Address http://192.168.1.102 -UserName root -Password notpass -GroupPath '/New Cameras' # Enable all camera channels on $hardware2 foreach ($camera in $hardware2 | Get-Camera) { $camera.Enabled = $true $camera.Save() }
-
Using Import-HardwareCsv
hardware.csv"HardwareName","HardwareAddress","UserName","Password" "Reception","http://192.168.1.102","root","notpass" "Shipping","http://192.168.1.103","root","notpass" "Parking","http://192.168.1.104","root","notpass"$recorder = Get-RecordingServer -Name Artemis Import-HardwareCsv -Path hardware.csv -RecordingServer $recorder
$cameras = Get-Hardware | ? Enabled | Get-Camera | ? Enabled
foreach ($camera in $cameras) {
$null = Get-Snapshot -Camera $camera -Live -Save -Path C:\demo\snapshots -UseFriendlyName -LocalTimestamp
}See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Josh Hendricks - LinkedIn - jh@milestonesys.com

