Public/Import-LprMatchListEntries.ps1
function Import-LprMatchListEntries { <# .SYNOPSIS Imports all rows from the provided CSV into the named LPR Match List. .DESCRIPTION Imports all rows from the provided CSV into the named LPR Match List. The only mandatory column name is RegistrationNumber. All other columns will be handled as custom fields. .EXAMPLE PS C:\> Import-LprMatchListEntries -Path .\lprlist.csv Exports all LPR Match List entries from the named LPR Match List to the file lprlist.csv in the current directory. #> [CmdletBinding()] param ( # Specifies the name of the LPR Match List into which the entries should be imported [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $Name, # Specifies the full path to the csv file where the LPR Match List entries should be exported [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string] $Path ) begin { $ms = Get-ManagementServer if ($null -eq $ms.LprMatchListFolder) { throw "Milestone XProtect LPR Plugin is not installed or was not loaded in the current session. Please ensure the plugin is installed. If LPR cannot be managed from Management Client on this system, it cannot be managed from PowerShell either." } } process { $list = $ms.LprMatchListFolder.LprMatchLists | Where-Object Name -eq $Name if ($null -eq $list) { Write-Error "No LPR Match List found matching name '$Name'" -Category ObjectNotFound return } $source = Import-Csv -Path $Path $entries = $source | ConvertTo-LprMatchListEntryList $list | Add-LprMatchListEntry -LprMatchListEntry $entries -Force } } |