powergate:code_reference:commandlets:remove-erpobject

Remove-ERPObject

Cmdlet to remove a specific entity from the ERP-System.

 Remove-ERPObject [[-EntitySet] <String>] [[-Keys] <Object>] [<CommonParameters>]

Type Name Description Optional
String EntitySetThe 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
Hashtable / PsObject KeysThe reference properties for the searching itemno

Bool:
$true ← on success.
$false ← on failure with an additional property 'Error' containing the Exception/ErrorMessage.

This commandlet is used to delete a specific object from the ERP System.

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

Remove Product with Id 1

Connect-ERP -Service "http://services.odata.org/V3/(S(xnnohcch2jddbn1z1ytpfni2))/OData/OData.svc/"
Remove-ErpObject -EntitySet "Products" -Keys @{"ID"=1}

Remove Product with Id 1

Connect-ERP -Service "http://services.odata.org/V3/(S(xnnohcch2jddbn1z1ytpfni2))/OData/OData.svc/"
Remove-ErpObject -EntitySet "Products" -Keys @{"ID"=1}

Search for Product and remove it

Connect-ERP -Service "http://services.odata.org/V3/(S(xnnohcch2jddbn1z1ytpfni2))/OData/OData.svc/"
$product = Get-ERPObject -EntitySet "Products" -Keys @{"ID"=10}
Remove-ErpObject -EntitySet "Products" -Keys $product._Keys