5.5.3 - PowerShell Extensions
Proventeq Migration Accelerator comes with a default PowerShell module called Proventeq.MigrationAccelerator.PowerShell.Module, which is delivered using the module manifest file Proventeq.MigrationAccelerator.PowerShell.Module.psd1. This has a default sub-module, called Proventeq.MigrationAccelerator.PowerShell.DefaultModule.psm1, which is an empty module (with one sample function).
In addition to writing PowerShell rules within the client UI, Proventeq Migration Accelerator provides the option to import custom PowerShell modules. This can be done in the following ways:
5.6.3.1. Upgrading the default module
Any custom functions and scripts can be written in the Proventeq.MigrationAccelerator.PowerShell.DefaultModule.psm1. These scripts and functions will be available in the Rule editor window in the client UI. Variables that are needed in the script during execution should be declared as a global variable e.g. $global:MyVariable
5.6.3.2. Creating new modules
A new PowerShell module can be created and included in the Proventeq Migration Accelerator Module manifest file as a nested module.
- Create a new PowerShell module file (PSM1 file)
- Create new functions and scripts in this module file
- Update the NestedModuleList property of MigrationAccelerator.PowerShell.Module.psd1 file to include this new module.
5.6.3.3. Importing metadata from CSV file
Metadata can be imported into Proventeq Migration Accelerator using the method specified in “Upgrading the default module” section.
Create a CSV file with a unique Item ID column, and columns for all the metadata associated with the item. Ensure the CSV file has headers.
ID, |
Metadata_1, |
Metadata_2, |
Metadata_3 |
0001, |
M1_value_1, |
M2_Value_1, |
M3_Value_1 |
0002, |
M1_value_2, |
M2_Value_2, |
M3_Value_2 |
0003, |
M1_value_3, |
M2_Value_3, |
M3_Value_3 |
Create a global variable and import the CSV:
$global:CSVMetadata = Import-CSV -path ‘<My csv path>’
In the Script mapping dialog, access the metadata by selecting the appropriate row by filtering it on the unique ID.
$meta = $global:CSVMetadata | ?{$_.ID –eq <My unique ID>}
$meta.Metadata_1
Testing PowerShell Functions
It is recommended to test any changes made to the PowerShell module prior to launching
PMA. The following steps can be executed to validate the changes,
- Open PowerShell console and import the Proventeq PowerShell module
- Invoke the custom function. If a CSV was imported into a custom variable, check the
value stored in the variable by typing the variable name in the console. If the values
from the CSV are available in the hash table, then the module is ready to be used by
Migration Accelerator.
Comments