I am looking to move some older list data into CRM 2011, so I wanted a way to create some “activities” via powershell. Below is the code to do that. In the first part of the code, I create a PowerShell object and then I convert it to a JSON object via PowerShell 3’s new ConvertTo-JSON cmdlet.
$JsonObject = New-Object psobject -Property @{ ActivityTypeCode = "appointment" Subject = "jbmurphy TEST" Description = "This is a descritpion" ScheduledStart = "2012-03-20T18:00:00Z" ScheduledEnd = "2012-03-20T18:00:00Z" Location = "Office" } # I am using PowerShell 3's ConvertTo-Json $jsonEntity=$JsonObject | ConvertTo-Json #$url="http://crmserver.company.com/OrgName/xrmservices/2011/OrganizationData.svc/EmailSet" #$url="http://crmserver.company.com/OrgName/xrmservices/2011/OrganizationData.svc/PhoneCallSet" $url="http://crmserver.company.com/OrgName/xrmservices/2011/OrganizationData.svc/AppointmentSet" $http_request = New-Object -ComObject Msxml2.XMLHTTP $http_request.open('POST', $url, $false) $http_request.setRequestHeader("Accept", "application/json") $http_request.setRequestHeader("Content-Type", "application/json; charset=utf-8") $http_request.send($jsonEntity) $http_request.statusText
Comments are closed.