Initializing variables
$pagingCookie=""
$page=1
$count=5000
Retrieve the Contact Record by XML
$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
$entity = [Microsoft.Xrm.Sdk.Entity]::new($varfetch.CrmRecords[0].logicalname, $varfetch.CrmRecords[0].contactid)
Add Attribute to $entity
$entity.Attributes.Add("firstname", "Khoday")
Finally, Update Service
$CRMConnection.Update($entity)
Final Code View
$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