Closed tdahnert closed 4 years ago
After some more troubleshooting I found the missing RequireNewInstance=True in my connection string was the issue. Once I had the keyword to search on I looked through closed Issues and found a number of people struggling with the same issue. Would be helpful to add this to the wiki if possible.
When I call the ExportSolution.ps1 and ImportSolution.ps1 from the same powershell session It's retaining the connection string from whichever script I called first and re-using it for my second call. I can call them in either order (Import then export) and it remembers the first connection I make instead of re-using it. It will continue to remember this connection string until I completely close out of powershell and re-open. If I then pass a different connection string in first, it will continue using that until I again close the session completely. I've been able to get around the issue by making the calls inside a Job instead. Because this is a different powershell session for each call it properly resolves the connection string and executes against the right CRM instance regardless of which call is first. Do you have any example of how to write a script to call the cmdlets so that they don't interfere with each other without resorting to jobs for each call?
This is how I was trying to invoke Invoke-Expression "& $commandExportFromdev"
This is how I can invoke successfully $Job = Start-Job -ScriptBlock { Invoke-Expression "& $using:JobCommand" }