The latest version of PSDataverse (v0.0.3) brings several quality and performance improvements. But, it also has a new command that lets you delete all the rows in a table in Dataverse as fast as it can be done. Here is the easiest way to use it:
Clear-DataverseTable lead
If you need to truncate multiple tables in one go, you can just pass multiple table names separated by comma.
Clear-DataverseTable lead, opportunity
You can also pipe the list of table names to Clear-DataverseTable
. This can be useful for when you are receiving the list from some other command.
@(lead, opportunity) | Clear-DataverseTable
Note that you should be already connected to Dataverse using ‘Connect-Dataverse’ before running the ‘Clear-DataverseTable`. This command is part of PSDataverse module that you can get from PowerShell Gallery. To know more, I suggest you read about it in here.
Good to know
When passing in a list of values separated by comma, PowerShell assumes that you are sending an array. The full syntax for literally defining an array is @(item1, item2,…). Knowing that, if you pass an array however way to the Clear-DataverseTable
it would work. To know more about arrays in PowerShell and all the different ways to define them, check About Arrays in the official documentation.
Leave a Reply