< Back

Get-D365CeODataEntityData

Mon Jan 13, 2020 8:42 am

NAME Get-D365CeODataEntityData



SYNOPSIS

Get data from an Data Entity using OData





SYNTAX

Get-D365CeODataEntityData [-ODataQuery <String>] [-Tenant <String>] [-URL <String>] [-ClientId <String>]

[-ClientSecret <String>] [-EnableException] [-RawOutput] [-OutputAsJson] [<CommonParameters>]



Get-D365CeODataEntityData -EntityName <String> [-ODataQuery <String>] [-Tenant <String>] [-URL <String>]

[-ClientId <String>] [-ClientSecret <String>] [-EnableException] [-RawOutput] [-OutputAsJson] [<CommonParameters>]





DESCRIPTION

Get data from an Data Entity using the OData endpoint of the Dynamics 365 Customer Engagement





PARAMETERS

-EntityName <String>

Name of the Data Entity you want to work against



The parameter is Case Sensitive, because the OData endpoint in D365CE is Case Sensitive



Remember that most Data Entities in a D365CE environment is named by its singular name, but most be retrieve

using the plural name



E.g. The account Data Entity is named "account", but can only be retrieving using "accounts"



Use the XRMToolBox (https://www.xrmtoolbox.com) to help you identify the names of the Data Entities that you

are looking for



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ODataQuery <String>

Valid OData query string that you want to pass onto the D365 OData endpoint while retrieving data



OData specific query options are:

$filter

$expand

$select

$orderby

$top

$skip



Each option has different characteristics, which is well documented at:

http://docs.oasis-open.org/odata/odata/ ... tions.html



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Tenant <String>

Azure Active Directory (AAD) tenant id (Guid) that the D365CE environment is connected to, that you want to

access through OData



Required? false

Position? named

Default value $Script:ODataTenant

Accept pipeline input? false

Accept wildcard characters? false



-URL <String>

URL / URI for the D365CE environment you want to access through OData



Required? false

Position? named

Default value $Script:ODataUrl

Accept pipeline input? false

Accept wildcard characters? false



-ClientId <String>

The ClientId obtained from the Azure Portal when you created a Registered Application



Required? false

Position? named

Default value $Script:ODataClientId

Accept pipeline input? false

Accept wildcard characters? false



-ClientSecret <String>

The ClientSecret obtained from the Azure Portal when you created a Registered Application



Required? false

Position? named

Default value $Script:ODataClientSecret

Accept pipeline input? false

Accept wildcard characters? false



-EnableException [<SwitchParameter>]

This parameters disables user-friendly warnings and enables the throwing of exceptions

This is less user friendly, but allows catching exceptions in calling scripts



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-RawOutput [<SwitchParameter>]

Instructs the cmdlet to include the outer structure of the response received from OData endpoint



The output will still be a PSCustomObject



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-OutputAsJson [<SwitchParameter>]

Instructs the cmdlet to convert the output to a Json string



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





The OData standard is using the $ (dollar sign) for many functions and features, which in PowerShell is

normally used for variables.



Whenever you want to use the different query options, you need to take the $ sign and single quotes into

consideration.



Example of an execution where I want the top 1 result only, with a specific city filled out.

This example is using single quotes, to help PowerShell not trying to convert the $ into a variable.

Because the OData standard is using single quotes as text qualifiers, we need to escape them with multiple

single quotes.



-ODataQuery '$top=1&$filter=address1_city eq ''New York'''



Tags: OData, Data, Entity, Query



Author: M????tz Jensen (@Splaxi)



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-D365CeODataEntityData -EntityName accounts -ODataQuery '$top=1'



This will get Accounts from the OData endpoint.

It will use the "Account" entity, and its EntitySetName / CollectionName "accounts".

It will get the top 1 results from the list of accounts.



It will use the default OData configuration details that are stored in the configuration store.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-D365CeODataEntityData -EntityName accounts -ODataQuery '$top=10&$filter=address1_city eq ''New York'''



This will get Accounts from the OData endpoint.

It will use the Account entity, and its EntitySetName / CollectionName "Accounts".

It will get the top 10 results from the list of accounts.

It will filter the entities for records where the "address1_city" is 'New York'.



It will use the default OData configuration details that are stored in the configuration store.











RELATED LINKS

Add-D365CeODataConfig

Get-D365CeActiveODataConfig

Set-D365CeActiveODataConfig