Initializing variables
C#
$pagingCookie=""
$page=1
$count=5000Retrieve the Contact Record by XML
C#
$varFetch = Get-CrmRecordsByFetch -conn $CRMConnection -Fetch @"
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="contact">
<attribute name="fullname" />
<attribute name="contactid" />
<order descending="true" attribute="fullname" />
</entity>
</fetch>
"@ -TopCount $count -PageNumber $page -PageCookie $pagingCookie
$pagingCookie=$varFetch.PagingCookie
$page++Add Record Logical Name and ID to $entity
C#
$entity = [Microsoft.Xrm.Sdk.Entity]::new($varfetch.CrmRecords[0].logicalname, $varfetch.CrmRecords[0].contactid)Add Attribute to $entity
C#
$entity.Attributes.Add("firstname", "Khoday")Finally, Update Service
C#
$CRMConnection.Update($entity)Final Code View
C#
$pagingCookie=""
$page=1
$count=5000
$varFetch = Get-CrmRecordsByFetch -conn $CRMConnection -Fetch @"
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="contact">
<attribute name="fullname" />
<attribute name="contactid" />
<order descending="true" attribute="fullname" />
</entity>
</fetch>
"@ -TopCount $count -PageNumber $page -PageCookie $pagingCookie
$pagingCookie=$varFetch.PagingCookie
$page++
$entity = [Microsoft.Xrm.Sdk.Entity]::new($varfetch.CrmRecords[0].logicalname, $varfetch.CrmRecords[0].contactid)
$entity.Attributes.Add("firstname", "Khoday")
$CRMConnection.Update($entity)Output



Join the conversation! Your thoughts help the community grow.