This project has moved. For the latest updates, please go here.

Get-CrmContent

Synopsis

Get data/records of an Entity

Syntax

Get-CrmContent [-Entity] <String> [[-Query] <Hashtable>] [[-Order] <Hashtable>] [-Columns <String[]>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [<CommonParameters>]

Get-CrmContent [-Entity] <String> [-Keys] <Hashtable> [-Columns <String[]>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [<CommonParameters>]

Get-CrmContent [-Entity] <String> [-Id] <Guid> [-Columns <String[]>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [<CommonParameters>]

Get-CrmContent [-FetchXml] <XmlDocument> [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [<CommonParameters>]

Description

Get records from an Entity based on an AttributeQuery, a FetchXML, an ID or Keys. When non provided all records are returned.
This cmdlet supports paging.

Parameters

-Entity <String>

Logicalname of the entity to get records from

Required? True
Position? 1
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Query <Hashtable>

Attribute query to use

Required? False
Position? 2
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Order <Hashtable>

Order result by columns

Required? False
Position? 3
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Columns <String[]>

Array of columnnames to retrieve.
Example: @('firstname', 'lastname', 'fullname')

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-IncludeTotalCount <SwitchParameter>

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Skip <UInt64>

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-First <UInt64>

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Id <Guid>

Id of the record to retrieve

Required? True
Position? 2
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Keys <Hashtable>

Key values to retrieve record for.

Required? True
Position? 2
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-FetchXml <XmlDocument>

FetchXML query

Required? True
Position? 1
Default value  
Accept pipeline input? false
Accept wildcard characters? False

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, InformationAction, InformationVariable,
WarningAction, WarningVariable, OutBuffer, PipelineVariable and OutVariable.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Inputs

Outputs

Microsoft.Xrm.Sdk.Entity

Notes

Examples

Get content for entity

PS C:\> Get-CrmContent -Entity contact -Column firstname, lastname, fullname

Get all records from Contact and return only the values for columns Firstname, Lastname and Fullname

Get specific record

PS C:\> Get-CrmContent -Entity contact -Column firstname, lastname, fullname -Id a2319884-7290-e511-80d8-00155d006b16

Get specific record for entity based on Id

FetchXML

PS C:\> [xml]$xml = Get-Content -LiteralPath C:\Temp\FetchXML.xml
Get-CrmContent -FetchXml $xml

Get data from an entity using Fetch XML

Attribute Query

PS C:\> Get-CrmContent -Entity contact -Query @{ 'firstname' = 'Arjan' } -Order @{ 'lastname' = 'Ascending' }

Get contacts where firstname is 'Arjan', and order the result by Lastname

Use Keys

PS C:\> Get-CrmContent -Entity contact -Keys @{ 'contactnumber' = '123456' } -Order @{ 'lastname' = 'Ascending' }

Get contact based on key Contactnumber with value '12356', and order the result by Lastname

Related links

Entity Class https://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.entity.aspx

Last edited Mar 11 at 7:02 PM by amsoftware, version 2