Skip to main content

Posts

Showing posts from September, 2019

Enable Trace on Dynamcis 365 on premise using PowerShell

Enable trace settings through Windows PowerShell Note These changes made in Windows PowerShell do not update the Registry. These changes update the DeploymentProperties and ServerSettingsProperties tables in the MSCRM_CONFIG database. Register the cmdlets 1.      Log in to the administrator account on your Microsoft Dynamics CRM server. 2.      In a Windows PowerShell window, type the following command: Add-PSSnapin Microsoft.Crm.PowerShell To obtain a list of the current settings, type the following command: Get-CrmSetting TraceSettings Set the trace settings 1.      Type the following command: $setting = Get-CrmSetting TraceSettings 2.      Type the following command to enable tracing: $setting.Enabled=$True 3.      Type the following command to set the trace settings: Set-CrmSetting $setting 4.      Type the following command to get a current list of the trace settings: Get-CrmSetting TraceSettings To disable tracing through Windows PowerShe

Check and Create a Node in XML, if it does not existing using PowerShell

Here is a quick code snippet to Add a Node in XML from from the XPath, the following PowerShell function will search for the node hierarchy, if it does not exist then it will create it. function   CheckForXMLNode  {      param  (          $File , # File Path of XML to search the node          $NodePath     )      $nodes  =  $NodePath  -split  "/"      $path  =  "//Configuration"      # My Sample Node Path is like this # //Configuration/Farm/CustomParent/CustomChild      foreach  ( $node   in   $nodes ) {          if  ( ( $node  -ne  "" ) -and ( $node  -ne  "Configuration" ) ) {             [ xml ] $xml  =   Get-Content   $File              $PathToCheck  =  $path + "/" + $node              $NodeToCheck  =  $xml .SelectSingleNode ( $PathToCheck )              if (! $NodeToCheck ){                  Write-Host   " $node  Node does not existing. creating ...."  -NoNewline