RE: Exporting FetchXML files from MS Dynamics instead of using Advanced find
Hi silasng,
We can use following commands in PowerShell to download fetchxml of a specific view.
In Dynamics, it uses an entity called "savedquery" to save definition and properties of views in system, and fetchxml is also a property of the entity.
https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/savedquery


Therefore, we can retrieve fetchxml property of savedquery entity, create a variable to store the query, then use New-Item command to create a xml file.
Before running commands, make sure that you have connected to Dynamics, run command 1 to extract fetchxml of a specific view and check whether the result is what you want.
Command 1:
(Get-CrmRecords -EntityLogicalName savedquery -FilterAttribute name -FilterOperator "eq" -FilterValue "My Active Contacts" -Fields fetchxml).CrmRecords.fetchxml
Output:

Command 2:
If the output is correct, create a variable to save the result. (There is no output in this step.)
$query = (Get-CrmRecords -EntityLogicalName savedquery -FilterAttribute name -FilterOperator "eq" -FilterValue "My Active Contacts" -Fields fetchxml).CrmRecords.fetchxml
Command 3:
Create a new file in disk C, the value is from the variable.
New-Item -Path "c:\" -Name "My Active Contacts.xml" -ItemType "file" -Value $query
Now, our fetchxml has been saved as a xml file in root directory of disk C.



Regards,
Clofly