powergate:code_reference:commandlets:get-erpobjects

Get-ERPObjects

Cmdlet to search for specific entities depending on the passed arguments.

Get-ERPObjects [[-EntitySet] <String>] [[-Top] <int>] [[-OrderBy] <Object>] [[-Filter] <String>] [[-Expand] <String[]>] [[-Select] <String[]>] [<CommonParameters>]

Type Name Description Optional
StringEntitySetThe EntitySet name where the item is located.
It is also possible to specify additional namespaces or the whole url (e.g MaterialService/Materials, http://localhost:8080/PGS/ERP/MaterialService/Materials)
no
IntegerTopThe amount of how many items should be shownyes
StringFilterQuery what should be executed as a filteryes
String / Hashtable / Hashtable[]OrderByItems getting ordered by passed property name and/or directionyes
String[]ExpandNavigation property name(s) which should be expandedyes
String[]Selectreturns only the properties explicitly requested by the clientyes

Entity[] ← on success
empty ← on failure

This commandlet is used search for specific entities from the ERP.
The Filter argument allows you to specify a filter with OData syntax. More informations about the OData Filter syntax can be found here.
The OderBy argument can be specified as String, as hashtable or as an array of hashtables.

  • If the argument is specified as String then the entities are orderd ascending by the passed property name.
  • If the argument is specified as hashtable then the entities are orderd by the passed property name and direction ('Ascending' or 'Descending')
  • If the argument is specified as array of hashtables, the entities can be orderd by multiple properties, in the specified direction (See example below)

The Expand allows you to expand multiple navigation properties. As default if the expand argument is not specified then the entity will be returned without navigation properties.
The Select argument lets you receive only those properties which you want to have in the result.

In the following examples we are using the public OData Services (http://services.odata.org) for demonstration purposes:

Search for customers from the company 'Alfreds Futterkiste':

Connect-Erp -Service "http://services.odata.org/V4/Northwind/Northwind.svc/" 
$entity = Get-ERPObjects -EntitySet "Customers" -Filter "CompanyName eq 'Alfreds Futterkiste'"

Search for customers with a companyName starting with 'A':

Connect-Erp -Service "http://services.odata.org/V3/Northwind/Northwind.svc/" 
Get-ERPObjects -EntitySet "Customers" -Filter "startswith(CompanyName,'A')" 

Get categories:

Connect-Erp -Service "http://services.odata.org/V4/Northwind/Northwind.svc/" 
$entity = Get-ERPObjects -EntitySet "Categories"

Get first 3 Products:

Connect-Erp -Service "http://services.odata.org/V4/Northwind/Northwind.svc/" 
Get-ERPObjects -EntitySet "Products" -Top 3 

Get objects ordered by Name:

Connect-Erp -Service "http://services.odata.org/V4/Northwind/Northwind.svc/" 
Get-ERPObjects -EntitySet "Products" -OrderBy 'Name' 

Get objects ordered by the ProductName <Descending>:

Connect-Erp -Service "http://services.odata.org/V4/Northwind/Northwind.svc/" 
Get-ERPObjects -EntitySet "Products" -OrderBy @{'ProductName'='Descending'} 

Get objects ordered by the ProductName <Descending> and then the CategoryId <Ascending>:

Connect-Erp -Service "http://services.odata.org/V4/Northwind/Northwind.svc/" 
Get-ERPObjects -EntitySet "Products" -OrderBy @(@{'ProductName'='Descending'},@{'CategoryID'='Ascending'} ) 

Get objects ordered by the ProductName <Ascending> and then the CategoryId <Descending>:

Connect-Erp -Service "http://services.odata.org/V4/Northwind/Northwind.svc/" 
Get-ERPObjects -EntitySet "Products" -OrderBy @('ProductName',@{'CategoryID'='Descending'} ) 

Get all OrderID's of the available 'Orders':

Connect-ERP -Service "http://services.odata.org/V4/Northwind/Northwind.svc"
Get-ERPObjects -EntitySet "Orders" -Select "OrderID"