Forum Discussion

drhorg2230's avatar
drhorg2230
Copper Contributor
Jul 06, 2022

PowerShell query Dynamics 365/Dataverse tables attributes

This post is related to PowerShell scripting for Dynamics 365/Dataverse. I need to export metadata for 40 Dynamics 365/Dataverse tables(entities). For each table I have the list of columns to get metadata for : eg: account (account_col1, account_col2,..., account_col270). Each of the 40 tables can contain large number of columns/attributes, but I have the column list for each entity (not all columns of these entities are required). The metadata export should contain following columns :
tableName,
columnName(attribute)
Datatype,
Max_Length,
Precision,
Scale,
is_nullable.

Datatype example can be INT, decimal, etc. (for which precision and scale apply), or varchar, uniqueidentifier for which precision and scale are 0 but is captured in Max_Length. This metadata export will help pre-create tables on the destination relational database where the actual data will be imported (data has been export separate). I can see this metadata columns in SSMS by join from sys.columns, sys.objects, but cannot do this dynamically.
to create this metadata export I plan on using PowerShell. Looking for a similar PS script where can input tableName and columnName and get the 7 metadata info that I listed above for each of the table columns pairs. I found https://www.powershellgallery.com/packages/Microsoft.Xrm.Data.Powershell/2.1/Content/Microsoft.Xrm.D... but was not able to find all export columns that I need (eg: Datatype, precision, scale, is_nullable).

Can you help how I can get the 7 metadata columns as above for the Dataverse tables attributes? I would prefer in PowerShell.

 

Thank you!

No RepliesBe the first to reply

Resources