Connect-ERP
Allows to connect to a CatalogService with all its known services, directly to a single service or use an open Vault connection to retrieve configured settings from the ERP Integration Settings dialog.
Syntax
Connect-ERP [[-Service] <Uri>] [[-User] <String>] [[-Password] <String>] [-IgnoreCertificates] [-OnConnect <Scriptblock | String>] [<CommonParameters>]
Connect-ERP -UseSettingsFromVault [-OnConnect <Scriptblock | String>] [<CommonParameters>]
Parameters
Type |
Name |
Description |
Default value |
Optional |
---|---|---|---|---|
Service |
Url to the catalog service or directly to the required service |
yes |
||
String |
User |
Username which should have permission to read the Service |
yes |
|
String |
Password |
Password which matches with username |
yes |
|
SwitchParameter |
IgnoreCertificates |
If Flag is set the connection is set up in order to trust all certificates |
False |
yes |
Scriptblock / String |
OnConnect |
This script block or function will be executed before connecting to the service. More details below |
yes |
|
SwitchParameter |
UseSettingsFromVault |
Connect to services configured in ERP Integration Settings dialog for the currently connected Vault |
False |
no |
Return type
Bool:
$true ← on success.
$false ← on failure. Exception/ErrorMessage can be accessed using $Error.
If the cmdlet fails due to error responses returned by the ERP system, the $Error variable provides a WebRequestException .
Remarks
The cmdlet can connect to a CatalogService or directly to a specified Service.
When calling Connect-Erp
and passing a URL to a CatalogService the cmdlet automatically connects all the registered services with the same authentication that was used for the CatalogService itself.
Additionally the cmdlet can be called again for a single service with different authentication if that service is not available by using the authentication of the CatalogService.
When passing Credentials to the cmdlet it will use Basic Authentication to connect to the specified service.
OnConnect
The script block or the function name that is passed to the -OnConnect
parameter will be executed before connecting to the service.
A parameter $settings containing the connection settings will be passed, which allows to manipulate certain settings or even attaching to the BeforeRequest/AfterResponse handler.
When an exception is thrown within the script block or function no connection to the services is established.
When -OnConnect
is passed when connecting to a CatalogService the specified script block or function will be used for each contained service that will be connected automatically.
Configuration from Vault
When using the -UseSettingsFromVault
switch, the cmdlet uses the currently connected Vault to connect to all configured services and provides access to these configuration $ERPSettings variable.
The configuration can be changed for each Vault individually with the ERP Integration Settings dialog.
The cmdlet fails when the connected Vault is not properly configured:
For instance, in production Vaults, it’s essential to manually setup the connection to the correct ERP system.
When working with test-Vaults, administrators often overlook to add the necessary configurations to their productive Vaults, which leads to ERP integration issues after go-live.
However, problems can also arise from sudden changes to the ERP-endpoint itself.
During the trial period or evaluation phase - when no specific configuration has been made - the default settings for a connection to a public Demo ERP system are used.
This allows all the delivered ERP integration samples to be used out of the box.
Settings File
The cmdlet relies on a hidden Vault file ‘$/powerGate.settings’ which stores all settings of the ERP integration.
A Vault administrator can set the file permissions so that only selected users can check-in changes.
Read and download permissions are required by all Vault users working with the ERP integration in Vault Client, Inventor or the Job Server.
The the cmdlet downloads the current settings to C:\ProgramData\coolOrange\powerGate.settings.
Examples
In the following examples we are using public OData Services (http://services.odata.org) for demonstration purposes:
Connect to the Northwind Service
1 | Connect-ERP -Service "http://services.odata.org/V4/Northwind/Northwind.svc" |
Connect to a SAP service that requires authentication
1 | Connect-ERP -Service "http://sap.coolorange.com" -User "EX_DEMO" -Password "secret" -OnConnect $global:sapConnect |
Connect to a service via secured SSL connection and trust all certificates
1 | Connect-ERP -Service "https://services.odata.org/V4/Northwind/Northwind.svc" -IgnoreCertificates |
Using the -OnConnect parameter to add a header to each request
1 2 3 4 5 6 7 | Connect-ERP -Service "http://services.odata.org/V4/Northwind/Northwind.svc" -OnConnect { param($settings) $settings.BeforeRequest = [Action[System.Net.Http.HttpRequestMessage]] { param($request) $request.Headers.Add("Accept","application/json") } } |
Using multiple script blocks in -OnConnect parameter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | $outputService = { param($settings) Write-host "Connecting to the Service $($settings.BaseUri)" } $outputPreferredUpdateMethod = { param($settings) Write-host "Current PreferredUpdateMethod is $($settings.PreferredUpdateMethod)" } Connect-ERP -Service "http://services.odata.org/V4/Northwind/Northwind.svc" -OnConnect { param($settings) $outputService.Invoke($settings) $outputPreferredUpdateMethod.Invoke($settings) $sapConnect.Invoke($settings) } |
Error handling, analyze the WebRequestException why the connection to server could not be established, using $Error:
1 2 3 4 5 6 7 8 | $result = Connect-ERP "https://services.odata.org/NotExisting.svsc" if(-not $result){ $Error[0].Exception.StatusCode #404 $Error[0].Exception.Source #Local computer $Error[0].Exception.Message #"The service is not available or could not be found on the server." $Error[0].Exception.RawResponse #"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." } |
Connect to all services which are configured for the connected Vault

1 2 3 4 | Import-Module powerVault Open-VaultConnection Connect-ERP -UseSettingsFromVault |