简体   繁体   English

Dynamics CRM导出解决方案(非本地)

[英]Dynamics CRM Export Solution (not on-premises)

I want to export a Dynamics CRM 365 solution. 我想导出Dynamics CRM 365解决方案。 Tools like the ALM Toolkit eg didn't worked. 例如ALM Toolkit之类的工具无法正常工作。

My Questions: 我的问题:

1) Is it possible to export the entire CRM365 solution by powershell at all? 1)是否可以通过powershell导出整个CRM365解决方案?

2) If it is not possible by powershell - is it possible by c#? 2)如果Powershell无法实现-c#是否可以实现?

I can connect to the crm withouth problems by powershell. 我可以通过Powershell毫无问题地连接到crm。 But If I try to call 但是如果我尝试打电话

When I call this: 当我这样称呼时:

$domain = "https://mypath.com"
$username = "user"
$password = "password"
$secPassword = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secPassword.AppendChar($_)}
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secPassword

$conn = Get-CrmConnection -Url "https://mypath.com" -Credential $credentials 
$exportPath = "C:\Users\xy\Data" 
Import-Module "C:\Users\xy\Scripts\Adxstudio.Xrm.PowerShell\Adxstudio.Xrm.PowerShell.dll" 
Export-CrmContent -Connection $conn -OutputPath $exportPath -Uncompressed -Generalized

I get the following error: 我收到以下错误:

Export-CrmContent : Metadata Contains A Reference That Cannot Be Resolved: "https://mypath/XRMServices/2011/Organization.svc?wsdl=wsdl0".
In C:\Users\my.ps1:14 Char:1
+ Export-CrmContent -Connection $conn -OutputPath $exportPath -Uncompre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Export-CrmContent], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Adxstudio.Xrm.PowerShell.Cmdlets.ExportCrmContent

But if I set up the $conn by using this: 但是,如果我使用以下命令设置了$ conn:

$conn= Get-CrmConnection -OrganizationName MyOrg -DeploymentRegion MyRegion -OnLineType Office365 -Credential $credentials 

I can get the organizations without problems. 我可以让组织毫无问题。 But when I try to call the export method with this connection I get: 但是,当我尝试通过此连接调用export方法时,我得到:

The Parameter "$conn" cannot be bound. The value "Microsoft.Xrm.Tooling.Connector.CrmServiceClient" of the type "Microsoft.Xrm.Tooling.Connector.CrmServiceClient" can't be converted to "Adxstudio.Xrm.PowerShell.Cmdlets.PsCrmConnection".

Are there any ideas to solve one of the both problems to export the crm solution? 有什么想法可以解决导出crm解决方案的两个问题之一吗?

Not tried the Powershell approach, but I've achieved this using C# in the past . 没有尝试过Powershell方法, 但是我过去已经使用C#实现了这一点

static void ExportUnManagedSolutions(IOrganizationService service, String directory)
{
    //Find all the solutions
    QueryExpression query = new QueryExpression
    {
        EntityName = "solution",
        ColumnSet = new ColumnSet("friendlyname", "uniquename", "version"),
        Criteria = new FilterExpression()
        {
            Conditions =
            {
                //Unmanaged solutions only
                new ConditionExpression("ismanaged", ConditionOperator.Equal, false),

                //These are special CRM solutions, which are marked as unmanaged but cant actually be exported
                new ConditionExpression("friendlyname", ConditionOperator.NotEqual, "Active Solution"),
                new ConditionExpression("friendlyname", ConditionOperator.NotEqual, "Default Solution"),
                new ConditionExpression("friendlyname", ConditionOperator.NotEqual, "Basic Solution"),
            }
        }
    };

    EntityCollection solutions = service.RetrieveMultiple(query);

    //For each solution found
    foreach (Entity s in solutions.Entities)
    {
        Console.WriteLine("Exporting " + s["friendlyname"]);

        //Perform a solution export
        ExportSolutionRequest request = new ExportSolutionRequest();
        request.Managed = false;
        request.SolutionName = (String)s["uniquename"];

        ExportSolutionResponse response = (ExportSolutionResponse)service.Execute(request);

        byte[] exportXml = response.ExportSolutionFile;
        string filename = (String)s["uniquename"] + " " + (String)s["version"] + ".zip";

        //This assumes the file directory already exists
        File.WriteAllBytes(directory + filename, exportXml);

        Console.WriteLine("Solution exported to {0}.", directory + filename);
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自动化从Dynamics CRM 2011导出默认解决方案的过程 - Automate the process of exporting the default solution from Dynamics CRM 2011 在本地Exchange邮箱上执行操作的推荐方法 - Recommended way to perform operations on on-premises Exchange mail box 如何从Azure调用本地脚本Powershell? - How can I call a script powershell on-premises from azure? 如何从本地TFS服务器2018使用REST Api获取多个提交? - How to GET multiple commits with REST Api from an on-premises TFS server 2018? 如何从 azure devops 管道到本地远程服务器运行 powershell 命令 - How to run powershell command from azure devops pipeline to on-premises remote server 将本地内容上载到SharePoint Online如何检索日志(使用Powershell) - Upload on-premises content to SharePoint Online how to retrieve the logs (using powershell) 无法更新本地主控目录同步对象的指定属性 - 更新 azure 广告中的用户管理器属性 - Unable to update the specified properties for on-premises mastered Directory Sync objects - Updating users manager attribute in azure ad 如何以编程方式将 a.bacpac 文件导入本地 SQL Server 实例? - How can I programmatically import a .bacpac file into an on-premises SQL Server instance? 是否可以使用Powershell添加和配置Dynamics CRM工作流程 - Is it possible to add and configure Dynamics CRM workflows with Powershell 列出Dynamics CRM 2013/2015中的实体关系 - List Entity Relationships in Dynamics CRM 2013/2015
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM