繁体   English   中英

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

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

我想导出Dynamics CRM 365解决方案。 例如ALM Toolkit之类的工具无法正常工作。

我的问题:

1)是否可以通过powershell导出整个CRM365解决方案?

2)如果Powershell无法实现-c#是否可以实现?

我可以通过Powershell毫无问题地连接到crm。 但是如果我尝试打电话

当我这样称呼时:

$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

我收到以下错误:

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

但是,如果我使用以下命令设置了$ conn:

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

我可以让组织毫无问题。 但是,当我尝试通过此连接调用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".

有什么想法可以解决导出crm解决方案的两个问题之一吗?

没有尝试过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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM