<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5442056460370397520</id><updated>2026-04-05T18:05:45.087-05:00</updated><category term="ms dynamics crm"/><category term="dynamics 2011"/><category term="SQL SERVER"/><category term="C#"/><category term=".NET"/><category term="SQL Server 2012"/><category term="dynamics 2013"/><category term="ASP.NET CORE"/><category term="Java"/><category term="SQL Server 2008"/><category term="xrm"/><category term="Kubernetes"/><category term="crm_int"/><category term="dynamics crm 2015"/><category term="javascript"/><category term="xml"/><category term="SSRS"/><category term="K8s"/><category term="SharePoint"/><category term="interview"/><category term=".NET Core"/><category term="BizTalk"/><category term="Docker"/><category term="plug-in"/><category term="Database"/><category term="crm javascript"/><category term="AJAX"/><category term="ASP.NET CORE MVC"/><category term="BizTalk 2010"/><category term="business intelligence"/><category term="email"/><category term="entity"/><category term="kubectl"/><category term="Azure"/><category term="Cloud"/><category term="SharePoint 2010"/><category term="crm sdk"/><category term="powershell"/><category term="visual studio"/><category term="ASP.NET CORE WEB API"/><category term="Apache Tomcat"/><category term="LINQ"/><category term="MOSS"/><category term="MYSQL"/><category term="PHP"/><category term="POD"/><category term="ReplicationController"/><category term="XSL"/><category term="YAML"/><category term="customization"/><category term="error"/><category term="option set"/><category term="ribbon"/><category term="ssis"/><category term="stored procedure"/><category term="NodePort"/><category term="OData"/><category term="ReplicaSet"/><category term="SignalR"/><category term="fetchxml"/><category term="jquery"/><category term="json"/><category term="security roles"/><category term="soap"/><category term="workflow"/><category term="xslt"/><category term="Blazor"/><category term="Deploymnet"/><category term="Eclipse"/><category term="EnableRule"/><category term="Google API"/><category term="Hubs"/><category term="JNDI"/><category term="QueryExpression"/><category term="Regex"/><category term="RetrieveMultiple"/><category term="RollingUpdate"/><category term="Visual Studio Code"/><category term="WCF"/><category term="catch exception"/><category term="credentials"/><category term="crm OrganizationService"/><category term="delete"/><category term="group"/><category term="import"/><category term="navigation"/><category term="orchestration"/><category term="pipeline"/><category term="plug-in code"/><category term="relationship"/><category term="report"/><category term="settings"/><category term="sub grid"/><category term="visual studio 2017"/><category term="web.config"/><category term="webservice"/><category term=".NET Core CLI"/><category term="Activities"/><category term="Azure SQL"/><category term="ColumnSet"/><category term="CustomRule"/><category term="Data Types"/><category term="Fields"/><category term="Grid"/><category term="Razor"/><category term="Regular Expressions"/><category term="RibbonDiffXml"/><category term="SQL Server 2017"/><category term="Service"/><category term="SmartCard"/><category term="WebAssembly"/><category term="active directory"/><category term="activityparty"/><category term="asp.net"/><category term="async"/><category term="attachment"/><category term="audit"/><category term="bulk"/><category term="cascading rules"/><category term="dll"/><category term="duplicate"/><category term="early bound"/><category term="excel"/><category term="export"/><category term="fault"/><category term="form"/><category term="header"/><category term="inheritance"/><category term="ldap"/><category term="lookup"/><category term="loop"/><category term="out"/><category term="processes"/><category term="rest"/><category term="rule"/><category term="security model"/><category term="session"/><category term="sessionstate"/><category term="state management"/><category term="strategy"/><category term="templates"/><category term="tracking"/><category term="views"/><category term="viewstate"/><category term="web resource"/><category term="web service"/><category term="404"/><category term="ADO.NET"/><category term="AccessRight"/><category term="AccessRightsMask"/><category term="Accesslevel"/><category term="AsyncoperationBase"/><category term="Attribute"/><category term="Azure Blob Storage"/><category term="Azure Container Registry"/><category term="Azure Data Box"/><category term="Azure Kubernetes"/><category term="B2b"/><category term="Backbone"/><category term="Best Practices"/><category term="Business unit"/><category term="C# 7.0"/><category term="CAPTCHA"/><category term="CTE"/><category term="CType"/><category term="Campaign"/><category term="Chart"/><category term="ClusterIP"/><category term="Code Analysis"/><category term="Code coverage"/><category term="CommandDefinition"/><category term="Common Table Expressions"/><category term="Concourse"/><category term="Coverlet"/><category term="CustomAction"/><category term="Data"/><category term="Decompressing"/><category term="Dependencies"/><category term="Dictionary"/><category term="Discovery"/><category term="DiscoveryService"/><category term="EAI"/><category term="EntityImages"/><category term="EntityReference"/><category term="EntityType"/><category term="Expression"/><category term="ExternalName"/><category term="FetchExpression"/><category term="FieldLevel"/><category term="FilteredStringMap"/><category term="GAC"/><category term="GetGlobalContext"/><category term="Guid"/><category term="IE"/><category term="IIS"/><category term="IPluginExecutionContext"/><category term="ITracingService"/><category term="InitialContext"/><category term="KeyValuePairOfstringstring"/><category term="Library"/><category term="LoadBalancer"/><category term="LocLabels"/><category term="Log"/><category term="MSCRMFETCH"/><category term="Nutritionix"/><category term="OrRule"/><category term="Organization"/><category term="Organization Service Methods"/><category term="OrganizationBase"/><category term="OrganizationData"/><category term="OrganizationService"/><category term="OrganizationServiceProxy"/><category term="Outlook"/><category term="PCF"/><category term="Parameters"/><category term="Pivotal"/><category term="PluginConfiguration"/><category term="PrincipalObjectAccess"/><category term="Privilege"/><category term="Privileges"/><category term="Programming Guidelines"/><category term="QueryByAttribute"/><category term="Requirement Levels"/><category term="Role"/><category term="RuleDefinition"/><category term="Script"/><category term="Server"/><category term="SonarQube"/><category term="Style Sheet"/><category term="TemplateAlias"/><category term="Transports"/><category term="ValueRule"/><category term="Web Page"/><category term="WhoAmI"/><category term="abstract"/><category term="action"/><category term="actions"/><category term="ad"/><category term="adapter"/><category term="algorithm"/><category term="alignment"/><category term="application navigation"/><category term="application ribbon"/><category term="application state"/><category term="area"/><category term="assemblies"/><category term="assembly"/><category term="auto number"/><category term="azd"/><category term="azure app service"/><category term="azure cli"/><category term="azure-cli"/><category term="backbone.js"/><category term="bash"/><category term="blob"/><category term="body"/><category term="boxing"/><category term="build"/><category term="bulk delete request"/><category term="button"/><category term="checkstyle"/><category term="chinable"/><category term="class"/><category term="client extensions"/><category term="clientside"/><category term="close"/><category term="cmd"/><category term="coalesce"/><category term="code generation tool"/><category term="collections"/><category term="command"/><category term="conditional"/><category term="conflict"/><category term="constructor"/><category term="context"/><category term="controls"/><category term="controlstate"/><category term="cookie"/><category term="cozyroc"/><category term="cozyroc ssis+"/><category term="crm save"/><category term="crm toolkit"/><category term="cron"/><category term="css"/><category term="customErrors"/><category term="dashboard"/><category term="data context"/><category term="datareader"/><category term="dataset"/><category term="debug"/><category term="debug directive"/><category term="dependency"/><category term="deploy"/><category term="depth"/><category term="designer"/><category term="developer toolkit"/><category term="diagnostics"/><category term="dialog"/><category term="digit separators"/><category term="displayrule"/><category term="dynamic entity"/><category term="el. underscore.js"/><category term="email router"/><category term="endpoint"/><category term="entity ribbon"/><category term="enum"/><category term="event"/><category term="events"/><category term="exception"/><category term="extension methods"/><category term="failure"/><category term="feed"/><category term="filter expression"/><category term="flyoutanchor"/><category term="footer"/><category term="fullname"/><category term="generics"/><category term="git"/><category term="global"/><category term="gmail"/><category term="grid page limit"/><category term="hide"/><category term="ildasm"/><category term="ilmerge"/><category term="image"/><category term="import file"/><category term="import large file"/><category term="intellisense"/><category term="is expression"/><category term="islolation"/><category term="isnull"/><category term="javascriptfunction"/><category term="json.net"/><category term="jumbselector"/><category term="late bound"/><category term="linux"/><category term="lists"/><category term="local"/><category term="loop detection"/><category term="luhn"/><category term="mail"/><category term="mail merge"/><category term="map"/><category term="mapping"/><category term="mappings"/><category term="maps"/><category term="mass email"/><category term="maxBufferSize"/><category term="maxReceivedMessageSize"/><category term="menu"/><category term="merge"/><category term="message assignment"/><category term="message bar"/><category term="messagebox"/><category term="metadata"/><category term="mobile"/><category term="models"/><category term="name format"/><category term="node"/><category term="notes"/><category term="npi"/><category term="objecttypecode"/><category term="onchange"/><category term="onclick"/><category term="onmousemove"/><category term="orchestation"/><category term="package type"/><category term="pagelimit"/><category term="pagination"/><category term="pattern matching"/><category term="performance"/><category term="personal options"/><category term="pick list"/><category term="picklist"/><category term="poa"/><category term="podman"/><category term="ports"/><category term="privacy preferences"/><category term="profile properties"/><category term="profiler"/><category term="programming model"/><category term="query"/><category term="query attribute"/><category term="query expression"/><category term="react"/><category term="receive"/><category term="ref"/><category term="reflection"/><category term="register"/><category term="reportviewer"/><category term="routing"/><category term="ruledefinitions"/><category term="sandbox"/><category term="save"/><category term="schema"/><category term="schemas"/><category term="scope"/><category term="sdk"/><category term="sections"/><category term="secureConfig"/><category term="security roles. odata"/><category term="selectedItemCount"/><category term="selectedItemIds"/><category term="send"/><category term="sequences"/><category term="sharing"/><category term="sitemap"/><category term="smtp"/><category term="string"/><category term="struct"/><category term="subarea"/><category term="sync"/><category term="system job"/><category term="table looping"/><category term="tabs"/><category term="team"/><category term="textpad"/><category term="tfs"/><category term="throw exception"/><category term="title"/><category term="tools"/><category term="top bar"/><category term="trusts"/><category term="tuples"/><category term="type casting"/><category term="unboxing"/><category term="urlMappings"/><category term="user"/><category term="virutal"/><category term="web_access"/><category term="wsdl"/><category term="xrm.page"/><category term="zend"/><title type='text'>Daynight</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://makdns.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/-/ms+dynamics+crm?max-results=5'/><link rel='alternate' type='text/html' href='http://makdns.blogspot.com/search/label/ms%20dynamics%20crm'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/-/ms+dynamics+crm/-/ms+dynamics+crm?start-index=6&amp;max-results=5'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>84</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>5</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5442056460370397520.post-6884290682839064911</id><published>2017-11-09T17:02:00.000-06:00</published><updated>2017-11-09T17:03:21.266-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ms dynamics crm"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><title type='text'>PowerShell - MS Dynamics CRM CRUD Operations</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;http://makdns.blogspot.com/2017/11/powershell-read-appconfig.html&quot; target=&quot;_blank&quot;&gt;Please refer Read App.Config&lt;/a&gt; -&lt;br /&gt;
&lt;a href=&quot;http://makdns.blogspot.com/2017/11/powershell-connect-ms-dynamics-crm.html&quot; target=&quot;_blank&quot;&gt;Please refer Connect MS Dynamics CRM&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
$crm_service = Invoke-CRMConn -OrganizationUrl $crm_organization_url -UserName $crm_username -Password $crm_password&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;## 1. To test the connection, check who you are:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
function WhoAMI() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $request = new-object Microsoft.Crm.Sdk.Messages.WhoAmIRequest&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $crm_service.Execute($request)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;#&lt;br /&gt;
&amp;nbsp; &amp;nbsp; UserId&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: 0dc96a70-952d-e611-80f0-0050568c6c1c&lt;br /&gt;
&amp;nbsp; &amp;nbsp; BusinessUnitId : a6099f28-952d-e611-80ec-0050568c6c1c&lt;br /&gt;
&amp;nbsp; &amp;nbsp; OrganizationId : 0d67a31e-952d-e611-80ec-0050568c6c1c&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ResponseName&amp;nbsp; &amp;nbsp;: WhoAmI&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Results&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : {[UserId, 0dc96a70-952d-e611-80f0-0050568c6c1c], [BusinessUnitId, a6099f28-0caf-e611-80ec-0050568c6c1c],&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[OrganizationId, 0d67a31e-0caf-e611-80ec-0050568c6c1c]}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ExtensionData&amp;nbsp; : System.Runtime.Serialization.ExtensionDataObject&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #&amp;gt;&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;## 2. Query for all existing contact details&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
function GetList() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $account_qry = New-Object Microsoft.Xrm.Sdk.Query.QueryExpression(&quot;account&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $account_qry.ColumnSet = New-Object Microsoft.Xrm.Sdk.Query.ColumnSet(&quot;name&quot;, &quot;accountnumber&quot;, &quot;industrycode&quot;, &quot;parentaccountid&quot;, &quot;ownerid&quot;, &quot;statecode&quot;, &quot;statuscode&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #$account_qry.Criteria.AddCondition(&quot;industrycode&quot;, [Microsoft.Xrm.Sdk.Query.ConditionOperator]::NotNull);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #$account_qry.Criteria.AddCondition(&quot;accountnumber&quot;, [Microsoft.Xrm.Sdk.Query.ConditionOperator]::Equal, &#39;LANG016&#39;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $account_qry.AddOrder(&quot;name&quot;, [Microsoft.Xrm.Sdk.Query.OrderType]::Ascending);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ## RetrieveMultiple returns a maximum of 5000 records by default.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ## If you need more, use the response&#39;s PagingCookie.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $account_response = $crm_service.RetrieveMultiple($account_qry)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ## create a dictionary that maps each account key is (name, accountnumber) &amp;amp; id is accountid:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $account_dic = @{ }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $account_response.Entities | ForEach-Object {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $name = $_.Attributes[&quot;name&quot;];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $accountnumber = $_.Attributes[&quot;accountnumber&quot;];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $industrycode = $_.Attributes[&quot;industrycode&quot;].value&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $statecode = $_.Attributes[&quot;statecode&quot;].value&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $statuscode = $_.Attributes[&quot;statuscode&quot;].value&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $parentaccountid = $_.Attributes[&quot;parentaccountid&quot;] ## $parentaccountid.Id&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ownerid = $_.Attributes[&quot;ownerid&quot;]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $value = (&quot;{0}|{1}|{2}|{3}|{4}|{5}|{6}&quot; -f @($name, $accountnumber, $industrycode, $parentaccountid.Name, $ownerid.Name, $statecode, $statuscode))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account_dic.Add($_.Id, $value)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ## account_dic contact values&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $account_dic.GetEnumerator() | ForEach-Object{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account = &#39;Account {0} -&amp;nbsp; {1}&#39; -f $_.key, $_.value&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Output $account&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;#&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Account efe7e3ac-9fc5-e711-80f7-0050568c5bd0 -&amp;nbsp; SQL Server|LANG200|18|C#|UAT|0|1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Account dc57a4c1-8bc5-e711-80f7-0050568c5bd0 -&amp;nbsp; PowerShell|LANG016|8||DNS|1|2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #&amp;gt;&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;## 3. Insert new entity record&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
function InsertEntity() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [CmdletBinding()]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; param(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=0, Mandatory=$true)] [string]$Name,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=1, Mandatory=$true)] [string]$AccountNumber,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=2, Mandatory=$false)] [string]$IndustryCode,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=3, Mandatory=$false)] [string]$ParentAccountID&lt;br /&gt;
&amp;nbsp; &amp;nbsp; )&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account = New-Object Microsoft.Xrm.Sdk.Entity(&quot;account&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Attributes[&quot;name&quot;] = $Name&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Attributes[&quot;accountnumber&quot;] = $AccountNumber&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($IndustryCode.Length -gt 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $industry_code_os = New-Object Microsoft.Xrm.Sdk.OptionSetValue($IndustryCode)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Attributes[&quot;industrycode&quot;] = [Microsoft.Xrm.Sdk.OptionSetValue] $industry_code_os&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($ParentAccountID.Length -gt 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account_ef = New-Object Microsoft.Xrm.Sdk.EntityReference(&#39;account&#39;, $ParentAccountID);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Attributes[&quot;parentaccountid&quot;] = [Microsoft.Xrm.Sdk.EntityReference]$account_ef;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $crm_service.Create($account)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; catch [Exception] {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo $_.Exception.Message&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;#&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Guid&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ----&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 54fad01a-a0c5-e711-80f7-0050568c5bd0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #&amp;gt;&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;## 4. Update existing entity record&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
function UpdateEntity() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [CmdletBinding()]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; param(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=0, Mandatory=$true)] [string]$ID,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=1, Mandatory=$true)] [string]$Name,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=2, Mandatory=$true)] [string]$AccountNumber,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=3, Mandatory=$false)] [string]$IndustryCode,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=4, Mandatory=$false)] [string]$ParentAccountID&lt;br /&gt;
&amp;nbsp; &amp;nbsp; )&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account = New-Object Microsoft.Xrm.Sdk.Entity(&quot;account&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Id = $ID&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Attributes[&quot;name&quot;] = $Name&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Attributes[&quot;accountnumber&quot;] = $AccountNumber&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($IndustryCode.Length -gt 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $industry_code_os = new-object Microsoft.Xrm.Sdk.OptionSetValue($IndustryCode)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Attributes[&quot;industrycode&quot;] = [Microsoft.Xrm.Sdk.OptionSetValue] $industry_code_os&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($ParentAccountID.Length -gt 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account_ef = New-Object Microsoft.Xrm.Sdk.EntityReference(&#39;account&#39;, $ParentAccountID);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account.Attributes[&quot;parentaccountid&quot;] = [Microsoft.Xrm.Sdk.EntityReference]$account_ef;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $crm_service.Update($account)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; catch [Exception] {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo $_.Exception.Message&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;## 5. Delete existing entity record&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
function DeleteEntity() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [CmdletBinding()]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; param(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=0, Mandatory=$true)] [string]$ID&lt;br /&gt;
&amp;nbsp; &amp;nbsp; )&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $crm_service.Delete(&#39;account&#39;, $ID)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; catch [Exception] {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo $_.Exception.Message&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;## 6. Change owner&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
function AssignOwner() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [CmdletBinding()]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; param(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=0, Mandatory=$true)] [string]$SystemUserID,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=1, Mandatory=$true)] [string]$AccountID&lt;br /&gt;
&amp;nbsp; &amp;nbsp; )&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $team_ef = New-Object Microsoft.Xrm.Sdk.EntityReference(&#39;systemuser&#39;, $SystemUserID);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account_ef = New-Object Microsoft.Xrm.Sdk.EntityReference(&#39;account&#39;, $AccountID);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $request = New-Object Microsoft.Crm.Sdk.Messages.AssignRequest;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $request.Assignee = $team_ef;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $request.Target = $account_ef;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $crm_service.Execute($request)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; catch [Exception] {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo $_.Exception.Message&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;#&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResponseName Results ExtensionData&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ------------ ------- -------------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Assign&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{}&amp;nbsp; &amp;nbsp; &amp;nbsp; System.Runtime.Serialization.ExtensionDataObject&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #&amp;gt;&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;## 7. Change state &amp;amp; status of existing record&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
function ChangeStatus(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [CmdletBinding()]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; param(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=0, Mandatory=$true)] [string]$AccountID,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=1, Mandatory=$true)] [string]$State,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=2, Mandatory=$true)] [string]$Status&lt;br /&gt;
&amp;nbsp; &amp;nbsp; )&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $request = New-Object Microsoft.Crm.Sdk.Messages.SetStateRequest;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $account_ef = New-Object Microsoft.Xrm.Sdk.EntityReference(&#39;account&#39;, $AccountID);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $request.EntityMoniker&amp;nbsp; &amp;nbsp;= $account_ef;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $request.State&amp;nbsp; = New-Object Microsoft.Xrm.Sdk.OptionSetValue($State);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $request.Status = New-Object Microsoft.Xrm.Sdk.OptionSetValue($Status);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $crm_service.Execute($request)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; catch [Exception] {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo $_.Exception.Message&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;#&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResponseName Results ExtensionData&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ------------ ------- -------------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Assign&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{}&amp;nbsp; &amp;nbsp; &amp;nbsp; System.Runtime.Serialization.ExtensionDataObject&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #&amp;gt;&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
WhoAMI&lt;br /&gt;
GetList&lt;br /&gt;
InsertEntity -Name &#39;SQL Server&#39; -AccountNumber &#39;LANG200&#39; -IndustryCode 18 -ParentAccountID &#39;0000a7d7-0000-0000-0000-082e5f2a3b8c&#39;&lt;br /&gt;
UpdateEntity -ID &#39;00000991-0000-0000-0000-0050568c5bd0&#39; -Name &#39;C#&#39; -AccountNumber &#39;LANG004&#39; -ParentAccountID &#39;0000a7d7-0000-0000-0000-082e5f2a3b8c&#39;&lt;br /&gt;
DeleteEntity -ID &#39;000032a2-0000-0000-0000-0050568c5bd0&#39;&lt;br /&gt;
AssignOwner -SystemUserID &#39;000077A8-0000-0000-0000-0050568C2FC0&#39; -AccountID &#39;0000a4c1-0000-0000-0000-0050568c5bd0&#39;&lt;br /&gt;
ChangeStatus -AccountID &#39;0000a4c1-0000-0000-0000-0050568c5bd0&#39; -State &#39;1&#39; -Status &#39;2&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5442056460370397520/6884290682839064911' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/6884290682839064911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/6884290682839064911'/><link rel='alternate' type='text/html' href='http://makdns.blogspot.com/2017/11/powershell-ms-dynamics-crm-crud.html' title='PowerShell - MS Dynamics CRM CRUD Operations'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5442056460370397520.post-9034759336707258556</id><published>2017-11-09T10:22:00.000-06:00</published><updated>2017-11-09T10:22:09.521-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ms dynamics crm"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><title type='text'>PowerShell - Connect MS Dynamics CRM</title><content type='html'>&lt;div class=&quot;code1&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;## create crm connction function, call this function with arguments&amp;nbsp;&amp;nbsp;OrganizationURL, UserName, Password&lt;/b&gt;&lt;br /&gt;
function Invoke-CRMConn {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;## pass arguments OrganizationURL, UserName, Password&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [CmdletBinding()]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; param(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=0, Mandatory=$true)] [string]$OrganizationURL,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=1, Mandatory=$true)] [string]$UserName,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Position=2, Mandatory=$true)] [string]$Password&lt;br /&gt;
&amp;nbsp; &amp;nbsp; )&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;## get directory path&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $current_directory =&amp;nbsp; $(Get-Item ($MyInvocation.ScriptName)).DirectoryName&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;## load crm &amp;amp; xrm dll&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $xrm_dll = $current_directory + &quot;/microsoft.xrm.sdk.dll&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $crm_dll = $current_directory + &quot;/microsoft.crm.sdk.proxy.dll&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [void][System.Reflection.Assembly]::LoadFile($xrm_dll)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [void][System.Reflection.Assembly]::LoadFile($crm_dll)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [void][System.Reflection.Assembly]::LoadWithPartialName(&quot;system.servicemodel&quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;## create credentials&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $clientCredentials = new-object System.ServiceModel.Description.ClientCredentials&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $clientCredentials.UserName.UserName = $UserName&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $clientCredentials.UserName.Password = $Password&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;## create&amp;nbsp; organization service proxy&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $service = new-object Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy($OrganizationURL, $null, $clientCredentials, $null)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;## use default crm time out or set 5 minutes of timeout.&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #$service.Timeout = new-object System.Timespan(0, 5, 0)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;## return service&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return $service&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;## test the service using who i am request&lt;/b&gt;&lt;br /&gt;
$service1 = Invoke-CRMConn -OrganizationURL &quot;https://dns.com/XRMServices/2011/Organization.svc&quot; -UserName &#39;test@dns.com&#39; -Password ABC123!@#&#39;&lt;br /&gt;
$request = new-object Microsoft.Crm.Sdk.Messages.WhoAmIRequest&lt;br /&gt;
$service1.Execute($request)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;#&lt;br /&gt;
UserId&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: 123ddfa0-9534-f234-8780-78900568c2fc0&lt;br /&gt;
BusinessUnitId : 456a043cf-0c34-e234-878c-78900568c6c1c&lt;br /&gt;
OrganizationId : 7895b3c2-0c34f-e234-878c-7890568c6c1c&lt;br /&gt;
ResponseName&amp;nbsp; &amp;nbsp;: WhoAmI&lt;br /&gt;
Results&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : {[UserId, 123ddfa0-952d-f234-8780-7890568c6c1c], [BusinessUnitId, 456a043cf-0caf-e234-8780-7890568c6c1c],&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[OrganizationId, 7895b3c2-0caf-e234-8780-7890568c6c1c]}&lt;br /&gt;
ExtensionData&amp;nbsp; : System.Runtime.Serialization.ExtensionDataObject&lt;br /&gt;
#&amp;gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;

</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5442056460370397520/9034759336707258556' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/9034759336707258556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/9034759336707258556'/><link rel='alternate' type='text/html' href='http://makdns.blogspot.com/2017/11/powershell-connect-ms-dynamics-crm.html' title='PowerShell - Connect MS Dynamics CRM'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5442056460370397520.post-5079327305416366014</id><published>2017-11-02T14:04:00.001-05:00</published><updated>2017-11-02T14:04:43.255-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dynamics crm 2015"/><category scheme="http://www.blogger.com/atom/ns#" term="ms dynamics crm"/><title type='text'>MSCRMMonitoringTest Logging &#39;Monitoring test failed: Test Title: Help Content Server Tests.: Machine: DNSSES1234: ServerRole: HelpServer&#39;</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;MSCRMMonitoringTest Logging &#39;Monitoring test failed: Test Title: Help Content Server Tests.: Machine: DNSSES1234: ServerRole: HelpServer&#39;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Every 15 minutes, CRM Logging the below error&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Event 18732, MSCRMMonitoringTest&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
Monitoring test failed: Test Title: Help Content Server Tests.: Machine: &amp;lt;Server_Name&amp;gt;: ServerRole: HelpServer&lt;br /&gt;
Test Log:&lt;br /&gt;
The remote server returned an error: (404) Not Found.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;at System.Net.HttpWebRequest.GetResponse()&lt;br /&gt;
&amp;nbsp; &amp;nbsp;at Microsoft.Crm.Monitoring.WebHelpers.GetWebResponse(String webpage, Boolean setCrmAuth, Boolean useProxy, Byte[] postData, Boolean setUserAgent, Int64 dmzPort)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;at Microsoft.Crm.Monitoring.Tests.HelpContent.VerifyHelpContent.TestDefaultHelp(TestResult result)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;at Microsoft.Crm.Monitoring.Tests.HelpContent.VerifyHelpContent.Execute()&lt;br /&gt;
&amp;nbsp; &amp;nbsp;at Microsoft.Crm.Monitoring.Engine.MonitoringRuntime.ExecuteMonitoringTest(MonitoringTestBase test, Int32 attempts)&lt;br /&gt;
&lt;br /&gt;
InnerException Type:System.Net.WebException&lt;br /&gt;
.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Workaround solution to fix the above logging error&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1. Create TestsToExclude.xml file,&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;MonitoringTestsToExclude&amp;gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Test isDisabled=&quot;true&quot;&amp;gt;VerifyHelpContent&amp;lt;/Test&amp;gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;/MonitoringTestsToExclude&amp;gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;2. Place it on %ProgramFiles%\Microsoft Dynamics CRM\Monitoring folder (all Servers).&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3. After 15 minutes, you see the log with succeded message&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;All monitoring tests succeeded: Machine: APWMAD0A2398: ServerRole: HelpServer.&lt;/div&gt;
</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5442056460370397520/5079327305416366014' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/5079327305416366014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/5079327305416366014'/><link rel='alternate' type='text/html' href='http://makdns.blogspot.com/2017/11/mscrmmonitoringtest-logging-monitoring.html' title='MSCRMMonitoringTest Logging &#39;Monitoring test failed: Test Title: Help Content Server Tests.: Machine: DNSSES1234: ServerRole: HelpServer&#39;'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5442056460370397520.post-2224240004447837305</id><published>2017-11-02T13:53:00.001-05:00</published><updated>2017-11-02T13:53:42.587-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dynamics crm 2015"/><category scheme="http://www.blogger.com/atom/ns#" term="ms dynamics crm"/><title type='text'>MSCRMMonitoringTest Logging &#39;A certificate registered for use by Microsoft Dynamics CRM has expired&#39;</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Every 15 minutes, CRM Logging the below errors&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Event 25089, MSCRMMonitoringTest&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
A certificate registered for use by Microsoft Dynamics CRM has expired.&amp;nbsp; Certificate type: TrustedIssuer Certificate Name: http://&amp;lt;URL&amp;gt;/adfs/services/trust Expiration Date: 1/11/2016 6:00:00 AM Store Location:&amp;nbsp; Store Name:
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Event 18797, MSCRMMonitoringTest&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;
Monitoring test failed: Test Title: Trusted Issuer Certificate test: Machine: &amp;lt;MACHINE_NAME&amp;gt;: ServerRole: DiscoveryService, Portal, ApiServer&lt;br /&gt;
Test Log:&lt;br /&gt;
Retrieving certificate data from config DBVerifying TrustedIssuer certificate.&amp;nbsp; Name=http://&amp;lt;URL&amp;gt;/adfs/services/trustTrustedIssuer certificate is not stored in local store:&amp;nbsp; It is contained in the config DB.&amp;nbsp; Name=http://&amp;lt;URL&amp;gt;/adfs/services/trustCertificate Lifespan:&amp;nbsp; Valid from 09/14/2014 19:00:00 to 01/11/2016 06:00:00Failure: Certificate has expiredVerifying TrustedIssuer certificate.&amp;nbsp; Name=http://&amp;lt;URL&amp;gt;/adfs/services/trustTrustedIssuer certificate is not stored in local store:&amp;nbsp; It is contained in the config DB.&amp;nbsp; Name=http://&amp;lt;URL&amp;gt;/adfs/services/trustCertificate Lifespan:&amp;nbsp; Valid from 10/12/2015 19:00:00 to 02/15/2017 06:00:00Remaining certificate lifespan 21.7 % is greater than the configured threshold of 10.0 %Certificate is not nearing expiration.
&lt;/div&gt;
&lt;br /&gt;
I found 2 expired (invalid) certificates on the servers (Deployment &amp;amp; all UI Servers).&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC3yeUwZtWx8InKHZR4Srtx4VWfl09L7ieIui74fBJKCEvVk8o1fgBNiteMAc2gGWGNhpgavYMjwWH8t48_TnxICHwm7HUzHALWK5AtuFWz4nDZ3Y1xyYgQaUN1dlaeA-vjx44cRPci3g/s1600/cetificate_error.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;93&quot; data-original-width=&quot;1176&quot; height=&quot;31&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC3yeUwZtWx8InKHZR4Srtx4VWfl09L7ieIui74fBJKCEvVk8o1fgBNiteMAc2gGWGNhpgavYMjwWH8t48_TnxICHwm7HUzHALWK5AtuFWz4nDZ3Y1xyYgQaUN1dlaeA-vjx44cRPci3g/s400/cetificate_error.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;b&gt;Workaround solution to fix the above logging error&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1. Delete older one (yellow color tag) certificate from all servers&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;A) Run cmd -&amp;gt; type mmc -&amp;gt; Console Root window -&amp;gt; File menu -&amp;gt; select Add/Remove Snap-ins&amp;nbsp;-&amp;gt; Add Cerificate -&amp;gt; Select(Computer account) -&amp;gt; Finish -&amp;gt; OK.&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;B) Console Root -&amp;gt; Certificates (Local Computer) -&amp;gt; Personal -&amp;gt; Certificates&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp;-&amp;gt; Select old cerificate (date ended with &#39;02/15/2017&#39; ) -&amp;gt; Delete.&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;2. Re run ‘Configure Claims-Based Authentication’ tool from CRM Deployment Manager.&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWplO5I-ioHeYnF9aMuMeL96ChkGQM63-GN59uEIZ6Cb3ZJAN-DV67n4s9ndxblD8vVjpy5tMSSiJnbpxSoZPgMAxYqQWpw27I57AddzamPHaxQzILHudGLv3WfRqMcblOl2dH7VP3Wzw/s1600/certificate_error.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;441&quot; data-original-width=&quot;454&quot; height=&quot;389&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWplO5I-ioHeYnF9aMuMeL96ChkGQM63-GN59uEIZ6Cb3ZJAN-DV67n4s9ndxblD8vVjpy5tMSSiJnbpxSoZPgMAxYqQWpw27I57AddzamPHaxQzILHudGLv3WfRqMcblOl2dH7VP3Wzw/s400/certificate_error.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3. After 15 minutes, you see the log with succeded message&lt;br /&gt;
&lt;div class=&quot;code1&quot;&gt;Monitoring test succeeded: Test Title: Trusted Issuer Certificate test: Machine: &amp;lt;MACHINE_NAME&amp;gt;: ServerRole: DiscoveryService, Portal, ApiServer&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Test Log:&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Retrieving certificate data from config DBVerifying TrustedIssuer certificate.&amp;nbsp; Name=http://&amp;lt;URL&amp;gt;/adfs/services/trustTrustedIssuer certificate is not stored in local store:&amp;nbsp; It is contained in the config DB.&amp;nbsp; Name=http://&amp;lt;URL&amp;gt;/adfs/services/trustCertificate Lifespan:&amp;nbsp; Valid from 10/12/2015 19:00:00 to 02/15/2017 06:00:00Remaining certificate lifespan 21.3 % is greater than the configured threshold of 10.0 %Certificate is not nearing expiration.&lt;/div&gt;&lt;/div&gt;
</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5442056460370397520/2224240004447837305' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/2224240004447837305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/2224240004447837305'/><link rel='alternate' type='text/html' href='http://makdns.blogspot.com/2017/11/mscrmmonitoringtest-logging-certificate.html' title='MSCRMMonitoringTest Logging &#39;A certificate registered for use by Microsoft Dynamics CRM has expired&#39;'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC3yeUwZtWx8InKHZR4Srtx4VWfl09L7ieIui74fBJKCEvVk8o1fgBNiteMAc2gGWGNhpgavYMjwWH8t48_TnxICHwm7HUzHALWK5AtuFWz4nDZ3Y1xyYgQaUN1dlaeA-vjx44cRPci3g/s72-c/cetificate_error.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5442056460370397520.post-2103723657711482933</id><published>2016-04-01T15:56:00.001-05:00</published><updated>2016-04-01T15:56:35.142-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="json"/><category scheme="http://www.blogger.com/atom/ns#" term="json.net"/><category scheme="http://www.blogger.com/atom/ns#" term="ms dynamics crm"/><title type='text'>Convert JSON to Object using Json.NET</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;sample json file&lt;/b&gt;&lt;br /&gt;
[{&quot;empNumber&quot;:&quot;123456&quot;,&quot;primaryName&quot;:{&quot;firstName&quot;:&quot;FN&quot;,&quot;lastName&quot;:&quot;LN&quot;},&quot;disability&quot;:false,&quot;otherNames&quot;:[{&quot;firstName&quot;:&quot;FN&quot;,&quot;lastName&quot;:&quot;LN1&quot;},{&quot;firstName&quot;:&quot;FN&quot;,&quot;lastName&quot;:&quot;LN2&quot;}],&quot;homeAddress&quot;:{&quot;addressLine1&quot;:&quot;1234 Python Java Rd&quot;,&quot;city&quot;:&quot;Bellevue&quot;,&quot;state&quot;:&quot;WI&quot;,&quot;postalCode&quot;:&quot;628204&quot;}},{&quot;empNumber&quot;:&quot;7890&quot;,&quot;primaryName&quot;:{&quot;firstName&quot;:&quot;1FN&quot;,&quot;lastName&quot;:&quot;1LN&quot;},&quot;disability&quot;:true,&quot;otherNames&quot;:[{&quot;firstName&quot;:&quot;1FN&quot;,&quot;lastName&quot;:&quot;1LN1&quot;},{&quot;firstName&quot;:&quot;1FN&quot;,&quot;lastName&quot;:&quot;1LN2&quot;}],&quot;homeAddress&quot;:{&quot;addressLine1&quot;:&quot;5869 Dotnet CRM St&quot;,&quot;city&quot;:&quot;Chicago&quot;,&quot;state&quot;:&quot;NE&quot;,&quot;postalCode&quot;:&quot;567567&quot;}}]&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Download Json.NET dll from http://www.newtonsoft.com/json&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;Class Objects&lt;/b&gt;&lt;br /&gt;
public class Names&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public string firstName { get; set; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public string lastName { get; set; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Address&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public string addressLine1 { get; set; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public string city { get; set; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public string state { get; set; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public string postalCode { get; set; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Employee&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public string empNumber { get; set; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Names primaryName { get; set; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public bool disability { get; set; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public IList&amp;lt;Names&amp;gt; otherNames { get; set; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Read the JSON file&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
string jsondatas = File.ReadAllText(JSONFile);&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Convert json datas to Employee object array&lt;/b&gt;&lt;br /&gt;
Employee[] emps = JsonConvert.DeserializeObject&amp;lt;Employee[]&amp;gt;(jsondatas);&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;for loop to get each object.&lt;/b&gt;&lt;br /&gt;
foreach (Employee emp in emps)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;//convert object back to json string&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; string jsonemp = Newtonsoft.Json.JsonConvert.SerializeObject(emp);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &lt;b&gt;&amp;nbsp; //convert json to object&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Employee emp1 = JsonConvert.DeserializeObject&amp;lt;Employee&amp;gt;(jsonemp);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5442056460370397520/2103723657711482933' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/2103723657711482933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5442056460370397520/posts/default/2103723657711482933'/><link rel='alternate' type='text/html' href='http://makdns.blogspot.com/2016/04/convert-json-to-object-using-jsonnet.html' title='Convert JSON to Object using Json.NET'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>