Asked by:
Crm Deployment Automation Through Power shell script?

Question
-
Hi
I want to automate the CRM deployment process using powershell script.Currently we are deploying manually.I know that We can not automate all the steps,but we can do automate some steps like import solution, plugins...etc.
Please share if you know the steps to deployment automation of CRM application
If you have any power shell scripts or any knowledge on this please share.
Thanks In Advance
Thanks&Regards,
Chaitanya.
- Edited by Chaitanya B Wednesday, May 14, 2014 12:47 PM
Wednesday, May 14, 2014 12:12 PM
All replies
-
You need xRM CI Framework.
Read this blog: http://waelhamze.com/2013/08/20/automated-crm-deployments-powershell/comment-page-1/
- Proposed as answer by Markuphub Wednesday, May 14, 2014 1:44 PM
Wednesday, May 14, 2014 1:22 PM -
Hi
I have tried the same.I am getting following error.We are using server 2008 r2 premium.poershell 2.0.
Import-Module : Cannot load Windows PowerShell snap-in C:\Program Files (x86)\Xrm CI Framework\CRM 2011\PowerShell Cmdl
ets\Xrm.Framework.CI.PowerShell.dll because of the following error: Unable to load one or more of the requested types.
Retrieve the LoaderExceptions property for more information.
Loader Exceptions:
Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf385
6ad364e35' or one of its dependencies. The system cannot find the file specified.I have searched for solution in online and I found that we need to install Powershell 3 and Windows Management Framework v3.How ever there are Pro's and corn's on installing this patch files. Could please suggest me on this?
For you reference please follow the below URL's.
https://visioautomation.codeplex.com/discussions/397034
http://mvcscaffolding.codeplex.com/discussions/437692
http://stackoverflow.com/questions/15473734/could-not-load-file-or-assembly-system-management-automation
http://serverfault.com/questions/458759/should-i-install-windows-management-framework-3-0?rq=1
Thursday, May 22, 2014 10:53 AM -
Yes you are right, you need WMF 3. but you can import solution with SDK.
Code from my Solution.
private void button1_Click(object sender, EventArgs e) { try { groupBox2.Enabled = false; exportLabel.Text = "Please wait.."; String solutionUniqueName = nameLabel.Text; QueryExpression querySampleSolution = new QueryExpression { EntityName = Solution.EntityLogicalName, ColumnSet = new ColumnSet(new string[] { "publisherid", "installedon", "version", "versionnumber", "friendlyname", "uniquename" }), Criteria = new FilterExpression() }; querySampleSolution.Criteria.AddCondition("uniquename", ConditionOperator.Equal, solutionUniqueName); Solution _solution = (Solution)this.service.RetrieveMultiple(querySampleSolution).Entities[0]; // Export or package a solution //Export an a solution String outputDir = pathTextBox.Text; ExportSolutionRequest exportSolutionRequest = new ExportSolutionRequest(); exportSolutionRequest.Managed = false; exportSolutionRequest.SolutionName = _solution.UniqueName; if (packageComboBox.SelectedItem.ToString() == "Unmanaged") { exportSolutionRequest.Managed = false; } else { exportSolutionRequest.Managed = true; } ExportSolutionResponse exportSolutionResponse = (ExportSolutionResponse)this.service.Execute(exportSolutionRequest); byte[] exportXml = exportSolutionResponse.ExportSolutionFile; string manage = ""; if (exportSolutionRequest.Managed) { manage = "_managed"; } else { manage = "_unmanaged"; } string filename = _solution.UniqueName + "_" + _solution.Version + manage + ".zip"; File.WriteAllBytes(outputDir + "\\" + filename, exportXml); exportLabel.Text = string.Format("Solution exported to {0}.", outputDir + "\\" + filename); groupBox2.Enabled = true; } catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>) { throw; } }
- Edited by Markuphub Thursday, May 22, 2014 12:53 PM
Thursday, May 22, 2014 12:49 PM -
Hi,
What you can do is have your own C# code do the import job (CRM calls, etc.). Once you have the code, build it into an assembly (.dll). Use PowerShell to invoke the .dll with necessary parameters. Make the C# code generic, with input parameters which you can pass from PowerShell, so it can be used in a generic way.
Friday, May 23, 2014 8:54 AM