< Back
Get-CrmRecord
Post
NAME Get-CrmRecord
SYNOPSIS
Retrieves a CRM record by specifying EntityLogicalName, record's Id (guid) and field names.
SYNTAX
Get-CrmRecord [-conn <CrmServiceClient>] [-EntityLogicalName] <String> [-Id] <Guid> [-Fields] <String[]>
[[-IncludeNullValue] <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
The Get-CrmRecord cmdlet lets you retrieve a record from your CRM organization. The retrieve results has two
properties for each field like name and name_Property.
The field with "_Property" contains field's logicalname and its Type information, and another field contains
"readable" value, which is either FormattedValue or extracted value from CRM special type like EntityReference.
The output also contains logical name of the Entity and original field which contains raw data. You can ignore
these two fields.
You can specify fields as fieldname1,fieldname2,fieldname3 syntax or * to retrieve all fields (not recommended for
performance reason.)
You can use Get-CrmEntityAttributes cmdlet to see all fields logicalname. The retrieved data can be passed to
several cmdlets like Set-CrmRecord, Removed-CrmRecord to further process it.
PARAMETERS
-conn <CrmServiceClient>
A connection to your CRM organizatoin. Use $conn = Get-CrmConnection <Parameters> to generate it.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-EntityLogicalName <String>
A logicalname for an Entity to retrieve. i.e.)accout, contact, lead, etc..
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Id <Guid>
An Id (guid) of the record
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Fields <String[]>
A List of field logicalnames. Use "fieldname1, fieldname2, fieldname3" syntax to specify Fields, or use "*" to
retrieve all fields (not recommended for performance reason.)
Required? true
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-IncludeNullValue [<SwitchParameter>]
Sepcify when you want to include fields even if it has null value. By default, all the fields doesn't include
value won't be returned.
Required? false
Position? 4
Default value
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
-------------------------- Example 1 --------------------------
Get-CrmRecord -conn $conn -EntityLogicalName account -Id be02caab-6c16-e511-80d6-c4346bc43dc0 -Fields
name,accountnumber
This example retrieves an account record with name and accountnumber fields. If the value of the field is null,
then it won't be returned.
name_Property : [name, A. Datum Corporation (sample)]
name : A. Datum Corporation (sample)
accountid_Property : [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]
accountid : be02caab-6c16-e511-80d6-c4346bc43dc0
original : {[name_Property, [name, A. Datum Corporation (sample)]], [name, A. Datum Corporation
(sample)], [accountid_Property, [accountid,
be02caab-6c16-e511-80d6-c4346bc43dc0]], [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]}
logicalname : account
-------------------------- Example 2 --------------------------
Get-CrmRecord account be02caab-6c16-e511-80d6-c4346bc43dc0 primarycontactid,statuscode
This example retrieves an account record with PrimaryContact and StateCode fields by omitting parameter names.
When omitting parameter names, you do not provide $conn, cmdlets automatically finds it.
accountid_Property : [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]
accountid : be02caab-6c16-e511-80d6-c4346bc43dc0
primarycontactid_Property : [primarycontactid, Microsoft.Xrm.Sdk.EntityReference]
primarycontactid : Rene Valdes (sample)
statuscode_Property : [statuscode, Microsoft.Xrm.Sdk.OptionSetValue]
statuscode : Active
original : {[accountid_Property, [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]], [accountid,
be02caab-6c16-e511-80d6-c4346bc43dc0],
[primarycontactid_Property, [primarycontactid, Microsoft.Xrm.Sdk.EntityReference]],
[primarycontactid, Microsoft.Xrm.Sdk.EntityReference]...}
logicalname : account
-------------------------- Example 3 --------------------------
Get-CrmRecord account 5b2fe1f3-b503-e511-80d4-c4346bc43dc0 *
This example retrieve an account record with all fields (which have values).
address2_addresstypecode_Property : [address2_addresstypecode, Microsoft.Xrm.Sdk.OptionSetValue]
address2_addresstypecode : Default Value
merged_Property : [merged, False]
merged : No
statecode_Property : [statecode, Microsoft.Xrm.Sdk.OptionSetValue]
statecode : Active
emailaddress1_Property : [emailaddress1, someone9@example.com]
emailaddress1 : someone9@example.com
......
-------------------------- Example 4 --------------------------
Get-CrmRecord -conn $conn -EntityLogicalName account -Id be02caab-6c16-e511-80d6-c4346bc43dc0 -Fields
name,accountnumber,websiteurl -IncludeNullValue
This example retrieves an account record with specified fields even if some of them are null value.
name_Property : [name, A. Datum Corporation (sample)]
name : A. Datum Corporation (sample)
accountid_Property : [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]
accountid : be02caab-6c16-e511-80d6-c4346bc43dc0
accountnumber :
accountnumber_Property :
websiteurl :
websiteurl_Property :
original : {[name_Property, [name, A. Datum Corporation (sample)]], [name, A. Datum Corporation
(sample)], [accountid_Property, [accountid,
be02caab-6c16-e511-80d6-c4346bc43dc0]], [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]}
logicalname : account
RELATED LINKS
SYNOPSIS
Retrieves a CRM record by specifying EntityLogicalName, record's Id (guid) and field names.
SYNTAX
Get-CrmRecord [-conn <CrmServiceClient>] [-EntityLogicalName] <String> [-Id] <Guid> [-Fields] <String[]>
[[-IncludeNullValue] <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
The Get-CrmRecord cmdlet lets you retrieve a record from your CRM organization. The retrieve results has two
properties for each field like name and name_Property.
The field with "_Property" contains field's logicalname and its Type information, and another field contains
"readable" value, which is either FormattedValue or extracted value from CRM special type like EntityReference.
The output also contains logical name of the Entity and original field which contains raw data. You can ignore
these two fields.
You can specify fields as fieldname1,fieldname2,fieldname3 syntax or * to retrieve all fields (not recommended for
performance reason.)
You can use Get-CrmEntityAttributes cmdlet to see all fields logicalname. The retrieved data can be passed to
several cmdlets like Set-CrmRecord, Removed-CrmRecord to further process it.
PARAMETERS
-conn <CrmServiceClient>
A connection to your CRM organizatoin. Use $conn = Get-CrmConnection <Parameters> to generate it.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-EntityLogicalName <String>
A logicalname for an Entity to retrieve. i.e.)accout, contact, lead, etc..
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Id <Guid>
An Id (guid) of the record
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Fields <String[]>
A List of field logicalnames. Use "fieldname1, fieldname2, fieldname3" syntax to specify Fields, or use "*" to
retrieve all fields (not recommended for performance reason.)
Required? true
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-IncludeNullValue [<SwitchParameter>]
Sepcify when you want to include fields even if it has null value. By default, all the fields doesn't include
value won't be returned.
Required? false
Position? 4
Default value
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
-------------------------- Example 1 --------------------------
Get-CrmRecord -conn $conn -EntityLogicalName account -Id be02caab-6c16-e511-80d6-c4346bc43dc0 -Fields
name,accountnumber
This example retrieves an account record with name and accountnumber fields. If the value of the field is null,
then it won't be returned.
name_Property : [name, A. Datum Corporation (sample)]
name : A. Datum Corporation (sample)
accountid_Property : [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]
accountid : be02caab-6c16-e511-80d6-c4346bc43dc0
original : {[name_Property, [name, A. Datum Corporation (sample)]], [name, A. Datum Corporation
(sample)], [accountid_Property, [accountid,
be02caab-6c16-e511-80d6-c4346bc43dc0]], [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]}
logicalname : account
-------------------------- Example 2 --------------------------
Get-CrmRecord account be02caab-6c16-e511-80d6-c4346bc43dc0 primarycontactid,statuscode
This example retrieves an account record with PrimaryContact and StateCode fields by omitting parameter names.
When omitting parameter names, you do not provide $conn, cmdlets automatically finds it.
accountid_Property : [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]
accountid : be02caab-6c16-e511-80d6-c4346bc43dc0
primarycontactid_Property : [primarycontactid, Microsoft.Xrm.Sdk.EntityReference]
primarycontactid : Rene Valdes (sample)
statuscode_Property : [statuscode, Microsoft.Xrm.Sdk.OptionSetValue]
statuscode : Active
original : {[accountid_Property, [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]], [accountid,
be02caab-6c16-e511-80d6-c4346bc43dc0],
[primarycontactid_Property, [primarycontactid, Microsoft.Xrm.Sdk.EntityReference]],
[primarycontactid, Microsoft.Xrm.Sdk.EntityReference]...}
logicalname : account
-------------------------- Example 3 --------------------------
Get-CrmRecord account 5b2fe1f3-b503-e511-80d4-c4346bc43dc0 *
This example retrieve an account record with all fields (which have values).
address2_addresstypecode_Property : [address2_addresstypecode, Microsoft.Xrm.Sdk.OptionSetValue]
address2_addresstypecode : Default Value
merged_Property : [merged, False]
merged : No
statecode_Property : [statecode, Microsoft.Xrm.Sdk.OptionSetValue]
statecode : Active
emailaddress1_Property : [emailaddress1, someone9@example.com]
emailaddress1 : someone9@example.com
......
-------------------------- Example 4 --------------------------
Get-CrmRecord -conn $conn -EntityLogicalName account -Id be02caab-6c16-e511-80d6-c4346bc43dc0 -Fields
name,accountnumber,websiteurl -IncludeNullValue
This example retrieves an account record with specified fields even if some of them are null value.
name_Property : [name, A. Datum Corporation (sample)]
name : A. Datum Corporation (sample)
accountid_Property : [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]
accountid : be02caab-6c16-e511-80d6-c4346bc43dc0
accountnumber :
accountnumber_Property :
websiteurl :
websiteurl_Property :
original : {[name_Property, [name, A. Datum Corporation (sample)]], [name, A. Datum Corporation
(sample)], [accountid_Property, [accountid,
be02caab-6c16-e511-80d6-c4346bc43dc0]], [accountid, be02caab-6c16-e511-80d6-c4346bc43dc0]}
logicalname : account
RELATED LINKS