PowerShell Wrapper Scripts for Anaplan Connect

An easy to use set of PowerShell wrapper scripts

This article outlines the features of the PowerShell scripts that are used as wrappers to the standard Anaplan Connect scripts. These PowerShell scripts will enable the following features:

  • A file watcher that waits for the arrival of files to start importing into Anaplan that can run through Enterprise Schedulers
  • Copy/move, import, and back up the source files as required after the Success or Failure of the import
  • Provide email notifications of the outcome of the processes
  • Can be used to trigger Actions on Anaplan that do not have file operations, but as required through schedulers

The scripts are avaliable in the links below.

GitHub Repository

Please contribute enhancements here: https://github.com/upaliw/anaplanconnect_ps

Releases

Contents of the ZIP file

The contents of the ZIP file are

contents.png

Object

Comments

exceptions

Folder to hold the errors/messages generated from Anaplan Connect

java_keystore

Folder to hold the Java KeyStore file for CA Certificate authentication. See the complete Anaplan Connect Guide.

lib

Folder that holds the required Java libraries to run Anaplan Connect

logs

Folder to hold the logging information of the PowerShell scripts

AnaplanClient.bat

anaplan-connect.jar

Anaplan Connect script and Java package

AnaplanConfig.bat

The connection details for Anaplan (i.e. Basic Authentication or CA Cert details)

Anaplan_Action.bat

Main script that runs the various types of Anaplan Actions

FileInterface.ini

Config file for all file-based operations

FileWatch.ps1

FileCopy.ps1

FileRun.ps1

Functions.ps1

Main PowerShell scripts for all operations

FW.bat

FWCPY.bat

FWCPYRUN.bat

RUN.bat

Windows batch scripts that can be used to call the main PowerShell scripts through Enterprise Schedulers

EmailNotifications.ini

Config file for email notification settings

EmailPassword.txt

Config file to hold the encrypted password for SMTP authentication 

Step 1 – Anaplan Connect Authentication

The following file should be updated as required to denote the connection type to Anaplan. The connection can be either one of the two possible types:

  1. Basic Authentication: Anaplan username and password, where the password is maintained by Anaplan and the Anaplan username is set to be an Exception user for SSO workspaces. The password will need to be reset every 90 days.
  2. CA Certificate Authentication: A client certificate procured using a Certification Authority that is attached to the Anaplan Username (see the Administration: Security - Certificates article in Anapedia).config.png

Step 2 – Email configuration

The following steps need to be completed for email notifications.

  1. Update the EmailNotifications.ini file with the SMTP parameters.smtp.png
  2. As required, create the encrypted password file txt for the SMTP authentication. To use the default encryption of PowerShell the following command can be issued in the PowerShell prompt and redirect the output to a file as:
    "smtpPassword" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File ".\EmailPassword.txt"Step 3 – File import configuration

Step 3 – File import configuration

This is the main configuration file for all the file import operations. The FileInterface.ini file will have the following information:fileinterface.png

Config Entry

Comments

Key

Mandatory: The main parameter passed to the scripts that picks all the details of the operations

Inbound filename

Optional: The inbound filename as a Regular Expression, so that it can recognize any timestamps

Load filename

Optional: The filename the Anaplan Action is tied to

Backup filename

Optional: The filename the file should be backed up as

Inbound location

Optional: The folder the file arrives to from a source system

Load location

Optional: The folder the file moves from the inbound location

Backup location

Optional: The folder where the backups are located, which is by date-stamped subfolders

Command to run

Mandatory: The Anaplan Action

Notify

Optional: One of Success, Fail, or Both

Notify email addresses

Optional: The email addresses comma (,) separated

Action Type

Mandatory: One of Import, Export, Process, Action, ImportAndProcess, JDBCImport, or JDBCProcess

Export filename

Optional: Only for Export Action Type

JDBC Properties file

Optional: Only for JDBCImport and JDBCProcess Action Type

Workspace GUID

Mandatory: Workspace ID

Model GUID

Mandatory: Model ID 

Calling the scripts

The scripts can be called manually or via an Enterprise Scheduler. The Key should be passed as the argument. The following scenarios can be provided as examples of these operations.

  1. Wait for an arrival of a file, then import it to Anaplan
FWCPYRUN “Key”
  1. Run an Anaplan action per schedule
RUN “Key”

Email notifications

If an email notification is enabled per config entry, a sample with an attachment of any exceptions generated will look like:email.png

Note: The email will contain 1 of 3 statuses

  1. Success: No issues.
  2. Success with data errors: Import was successful, but some data items had issues. There will be an attachment with the details of the exceptions generated from Anaplan.
  3. Fail: The import failed, details will be attached in the email.

Logging

All steps of the interface processes will be logged in the logs folder for each operation (i.e. FileWatch, FileCopy, and FileRun) separately. The generated exceptions will be in the exceptions folder. 

Note: There is no process to clean-up the older log files, which should be done on a case-by-case basis.

Labels (2)
Contributors