Import Automation

The Data Management tool includes a "Generate Upload Script" feature that allows you to import data without using a web browser. This script can be scheduled to run automatically, enabling hands-free data and photo synchronization on a daily basis.

Requirements

Before proceeding, ensure that you have a functioning File Import Configuration and Mapping set up.

As of October 13th, 2023, generating a script will create a "v2" script that will prompt you to create an Application. The previous v1 endpoint is now deprecated but will remain available until a sunset date is communicated.

Generate the Upload Script

Navigate to Data Management > Integrations > File Import

Select Actions > Generate Upload Script

At the Select or Create an Application prompt enter an application name such as “Data Import” then Save.

When working with multiple tenants we recommend using the Tenant name in the app name, such as ‘Tenant B Import’.

A Windows PowerShell script named “Import_[File Import Config]v2.ps1” will be downloaded.

Update PathToFile in the Upload Script

To configure the upload script to point to your import CSV or ZIP file, follow these steps:

  1. Locate the PowerShell script (.ps1) file you generated earlier.

  2. Right-click on the script file and select "Edit".

  3. The script will open in the Windows PowerShell Integrated Scripting Environment (ISE).

  4. Locate line 11 in the script, which should look like this:
    $PathToFile = ""

  5. Modify the value of the $PathToFile variable to point to the correct path of your import CSV or ZIP file on your local machine.

Unblock the script

Windows security may block the script when you try running it. The next step is to unblock the script using PowerShell 7 running as an administrator.

To run PowerShell 7:

  1. Click Start

  2. Type “PowerShell” into search

  3. Right-click PowerShell 7 > Run as Administrator.

To resolve the restricted execution policy issue use the command:

Unblock-File "FILENAME"

OR

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Enter Y to approve the change.

Run the script

Next, run the script. You will be prompted to a visit a URL - this only needs to be done one time. You will need to be signed in when visiting the link.

Hold Ctrl then click the link, or copy/paste the URL into a browser.

Upon successful verification the script will return StatusCode 200 and a credential file (in JSON format) will appear in the script folder.

Create a scheduled task

After you have confirmed the script can run successfully the next step is to automate the script execution.

Start > Windows Administrative Tools > Task Scheduler

Click Create Basic Task

Enter a Name for the Task

For the Trigger choose a frequency that aligns with how often the import file will be updated.

Select the option to Start a program

When specifying the Action you will need to enter the PowerShell executable path for the Program/script and the PowerShell script in a Command argument.

Program/script

"C:\Program Files\PowerShell\7\pwsh.exe"

Argument

-Command "C:\Path\ToThe\ScriptFile.ps1"

Select the option to Open the Properties dialog for this task when I click Finish

In the resulting Properties window we recommend you apply the following settings:

  1. Change the User or Group to a user that you want to execute the script

  2. Select the option to Run whether user is logged on or not

  3. Select the operating system in Configure for:

Click OK to save the scheduled task and input your password when prompted.

Here is an view of Task Scheduler showing the example EliteID Person Import.

Photo upload and automation

To streamline the process of creating a ZIP archive containing new or modified photos from the past 24 hours, you can use the PowerShell script provided below.

Preparing the Photo Upload ZIP Archive

  1. Download the PowerShell script:

  2. Open the script in a text editor and follow the setup instructions provided within the script.

  3. Run the script, and it will generate a ZIP archive containing only the new and modified photos from the past 24 hours.

Working with Multiple Tenants

When a user grants permission for the app to access data, the access token generated is specific to that user's tenant. This means each credential file (in JSON format) can only be used for a single tenant.

To support multiple tenants, you will need to create a separate app and credential file for each one. We recommend organizing your scripts and credential files into separate folders per tenant. This way, each script can save its unique credential file within its designated folder without requiring any modifications to the script itself.

For example, you could have a folder structure like this:

With this approach, your scripts can read the credential file from the current working directory, allowing you to work with different tenants seamlessly.