Using the powerGate Cmdlets

Start the PowerShell environment

In order to get started either open any PowerShell IDE and load the powerGate Module by calling Import-Module powerGate or open the powerGate Console shortcut in the start menu, which already loads powerGate for you.

Connect with ERP system

Before you are able to work with your ERP-System you have to connect to powerGateServer or directly your ERP system (if it support’s an OData interface).
This can be done by calling Connect-Erp.

Some public accessible OData-Services for testing can be found here.

Get multiple entities from ERP

After you are connected, you want to work with entities. In order to get the entities you have to know the appropriate EntitySet.
The list of available EntitySet’s can be retrieved with the Get-ERPEntitySets Cmdlet.

Note

If you want to get the names of the EntitySet’s you can access them via $entitySet.Name Now you know the name of the different entitiyTypes, therefore you can finally get some entities with Cmdlet Get-ErpObjects. Note Get-ErpObjects has many optional parameters like -Top -Filter -Expand. See detailed documentation for them. Get a specific entity from ERP In order to get a specific entity you have to know their key properties which identifies them. At this point you probably don’t know the key properties of the entity. This might help:  1 2 $allEntityTypes = Get-ERPEntityTypes $refPropNames =$allEntityTypes[0].Keys 

First set up the keys for your entity as a Hashtable:

 1 $keys = @{ Number="100001" Language="DE" }  Execute Get-ErpObject with the mandatory arguments EntitySet and Keys.  1 $entity = Get-ERPObject -EntitySet $entitySet.Name -Keys$keys 

Update an existing entity

In case you want to change some values of the entity you can achieve this with the Udpate-ErpObject Cmdlet.
First setup a Hashtable, with the values you want to update.

Note

Key properties can NOT be modified!

 1 $updatedProperties = @{ Type = "uranium" UnitOfMeasure = "Bq" }  Execute the Cmdlet with the entity-keys and properties and it returns the updated entity.  1 $updatedEntity = Update-ERPObject -EntitySet "Materials" -Keys $keys -Properties$updatedProperties 

 1 $newEntity = @{ Number = "100002" Type = "Einsteinium" UnitOfMeasure = "Bq", }  Execute the Cmdlet with the EntitySet you want the entity to create for and your entity hashtable as parameters.  1 Add-ERPObject -EntitySet "Materials" -Properties$newEntity