Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / Dynamix Academy / Export default solution in ...

Export default solution in Dynamics 365 / CRM Programmatically

Hello, everyone, and Dynamix Academy is back again with yet another How-To article. In this video article, we will see How to Programmatically export default solution in dynamics 365?

Many a time to we need to export the default solution. And mostly we will try to export the default solution using the Out of the Box export feature from the UI. But this will not guarantee that the default solution will successfully export or not.

Typical Errors during exporting default solution

For me, the classic way of exporting the default solution in Dynamics 365 was not working at all. I’m using MS 365 On-premise – V9.0. And I was unable to export the default solution dynamics 365. I was getting some typical Errors during exporting the default solution, saying Thread Being aborted after a lot of time and processing.

And I had also tried to exporting the whole default solution with all customizations of our testing environment. After 5 Minutes, the export stops with an error message, but no details. Digging in the logs I found an error, which is telling me, that the process was running into a timeout.

Export default solution in Dynamics 365 / CRM Programmatically

I have shown in the below video How to export the default solution in Dynamics CRM Programmatically?

How to programmatically export default solution in Dynamics 365 / CRM?

How to Export default solution in Dynamics 365 / CRM ?

Step 1) Download the ExportDefaultSolution.ps1 from here.

Step 2) Run your PowerShell ISE as Administrator.

Step 3) Open the ExportDefaultSolution.ps1 file in the PowerShell ISE

Open the Export Default Solution.ps1 in PowerShell ISE

or Copy the below code into new tab. And change the $SolutionFilePath according to your choice.

$error.clear()
$solutionName ="Default" 
$SolutionFilePath="C:\ExportedSolutionFolder"
$ErrorOccured = $false



Set-StrictMode -Version latest
function InstallRequiredModule{

try { 
        Get-PSRepository -WarningVariable wv
        if($wv.ToString() -eq "Unable to find module repositories")
        {
            [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 
            Register-PSRepository -Default
         }
        Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force
        $moduleName = “Microsoft.Xrm.Data.Powershell”
        $moduleVersion = “2.7.2”
        if (!(Get-Module -ListAvailable -Name $moduleName )) {
            Write-host “Module Not found, installing now”
            $moduleVersion
            Install-Module -Name $moduleName -MinimumVersion $moduleVersion -Force
        }
        else
        {
            Write-host “Module Found”
        }
     }
    catch { 
        "Error occured"
        $ErrorOccured = $true 
      }
    if (!$ErrorOccured) { "No Error Occured" }
}
function EstablishCRMConnection{

        try{
            write-host "Establishing crm connection next"
            $crm = Get-CrmConnection -InteractiveMode 
            write-host "Crm connection established"
        }
        catch{
            Write-Host $_.Exception
            }
        return $crm
}

InstallRequiredModule

#Update Source CRM instance details below:
Write-Host "going to create source connection"
$CrmSourceConnectionString = EstablishCRMConnection
Write-Host "source connection created"
Set-CrmConnectionTimeout -conn $CrmSourceConnectionString -TimeoutInSeconds 1000

Write-Host "Publishing Customizations in source environment"
Publish-CrmAllCustomization -conn $CrmSourceConnectionString
Write-Host "Publishing Completed in source environment."

Write-Host "Exporting Solution"
Export-CrmSolution -conn $CrmSourceConnectionString -SolutionName "$solutionName" -SolutionFilePath "$SolutionFilePath" -SolutionZipFileName "$solutionName.zip" 
Write-host "Solution Exported."

Step 4) Click on the Run the script button as shown below.

Can we export a default solution for back up and start customizing in unmanaged solution
Can we export a default solution for backup and start customizing in an unmanaged solution?

Step 5) It will show the Connection Interactive Dialog box. Enter your details properly and Click Login.

  • Deployment Type
  • Server
  • User Name
  • Password
  • Domain
  • Check the Display List of Avaliable Orgnaization
Default solution in Exporting a Default Solution in Dynamics 365 Programmatically
Default solution in Exporting a Default Solution in Dynamics 365 Programmatically

Step 6) Select the Organization that you want to Connect to for exporting a Default Solution in Dynamics 365.

microsoft dynamics 365 exporting a solution in dynamics 365
Dynamics 365 Export Default Solution

Step 7) Let the script execute, it will take some time to execute depending on the level of customizations that you have in the organization. Then it will show you the message “Solution Exported”.

exporting a default solution
Exporting a default solution

Step 8) Finally Verify the Exported Solution by navigating to the physical path that you have given in Step 3.

export default solution in dynamics 365 - Exporting a Default Solution in Dynamics 365
Exporting a Default Solution in Dynamics 365

Also, find More on Dynamix Academy :

Let’s Connect:

The post Export default solution in Dynamics 365 / CRM Programmatically appeared first on Dynamix Academy.

Comments

*This post is locked for comments