I am using the powershell script below to import a solution. It uses Microsoft.Xrm.Data.PowerShell, which in turn uses Microsoft.Xrm.Tooling.Connector.CrmServiceClient.ImportSolutionToCrm to import the solution. The code works just fine on my developer machine (Windows 7), but on our build agent (Windows Server 2012 R2), it hangs importing the CRM solution. With the XRM tooling tracing enabled and verbose turned on for the powershell commands, the last output I get is "Calling .ImportSolutionToCrm() this process can take minutes..." from the powershell module on the line before it calls the CrmServiceClient's ImportSolutionToCrm method. If I separately monitor the solution import logs in Dynamics 365, the solution imports fine in about 10-15 minutes. However, if I use Fiddler to watch the ImportSolutionRequest sent to the server, it just never completes. It stays at "download progress = 0 bytes."
I'm using the latest version of Microsoft.Xrm.Data.PowerShell (2.8.1.3), which in turn appears to use Microsoft.CrmSdk.XrmTooling.CoreAssembly version 9.0.2.4. I also have tried versions of Microsoft.Xrm.Data.PowerShell back to 2.8.0.
Also, this same script worked just fine on the same build agent before we upgraded Dynamics 365 from v8.2 to v9, and added the line about TLS 1.2 to the script. And, it works just fine if I use it to import a small test solution rather than our large solution.
I assume there's a setting somewhere in Windows on the build agent machines that causes the issue, but I'm not familiar with these things. Can anyone advise me where to look?
$username = 'my_username' $password = 'my_password' $orgname = 'my_org_name' $solutionFilePath = "$PSScriptRoot\my_solution.zip" Import-Module Microsoft.Xrm.Data.PowerShell # set up tracing $traceListener = New-Object System.Diagnostics.ConsoleTraceListener [Microsoft.Xrm.Tooling.Connector.TraceControlSettings]::TraceLevel = [System.Diagnostics.SourceLevels]::All [Microsoft.Xrm.Tooling.Connector.TraceControlSettings]::AddTraceListener($traceListener) # get the credential $securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential ($username, $securePassword) # connect to CRM [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 $conn = Get-CrmConnection -OrganizationName $orgname ` -OnLineType Office365 ` -Credential $credential ` -MaxCrmConnectionTimeOutMinutes 120 ` -ErrorAction Stop ` -Verbose # import the solution Import-CrmSolution -conn $conn -SolutionFilePath $solutionFilePath -MaxWaitTimeInSeconds 7200 -Verbose