簡體   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