2017-03-07 4 views
1

Dynamics CRM 365ソリューションをエクスポートします。例:ALM Toolkitのようなツール働いていませんでした。Dynamics CRMエクスポートソリューション(オンプレミスではありません)

私の質問:

1)それがすべてのPowerShellによって全体CRM365ソリューションをエクスポートすることは可能ですか?

2)PowerShellでできない場合は、C#で可能でしょうか?

私はpowershellでcrm withouth問題に接続できます。しかし、私は呼び出すと

を呼び出そうとした場合、この:

$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 

私は問題なく組織を得ることができます。私はこの接続でエクスポートメソッドを呼び出すしようとすると、しかし、私は取得:CRMソリューションをエクスポートする両方の問題の一つを解決するための任意のアイデアは

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". 

ありますか?

答えて

0

Powershellアプローチを試していない、but I've achieved this using C# in the past

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); 
    } 
} 
関連する問題