I'm trying to export all Power Automate solutions. Export-CrmSolution works one at a time, but breaks when I try to make it loop through the solution names. I've tried putting them into an array, putting the variable in quotes and parentheses, and making sure it is formatted as a string. Totally new to this module, so any help greatly appreciated!
$allSolutions = (Get-CrmRecords -EntityLogicalName solution -Fields *)
foreach($solution in $allSolutions)
{
$solutionname = $Solution.CrmRecords.friendlyname | Out-String
Export-CrmSolution -SolutionName $solutionname
}
Error:
Get-CrmRecordsByFetch : System.Management.Automation.RuntimeException: ************ FaultException`1 - RetrieveMultiple : GetEntityDataByFetchSearch |=> Sql error: A validation error occurred. A string value provided is too long. CRM ErrorCode: -2147012607 Sql ErrorCode: -2146232060 Sql Number: 8152
Fun Fact: Solved it. Thanks!
String Too Long? Filter to only visible solutions. Ex.
Where-Object{ $_.isvisible -eq "yes"}
Can't find solution by "Name"? It wants the record's UniqueName, not FriendlyName. Ex.
Export-CrmSolution "$($solution.uniquename)"
Boom, it works.