Preserve datatype name when converting to JSON with ConvertTo-Json

前端 未结 1 614
花落未央
花落未央 2021-01-21 14:25

I\'m trying to export my SSIS catalog environment to a JSON file (with PowerShell). When I select the right columns I see \"String\" and \"Int16\" as value for the Type: but wh

1条回答
  •  天涯浪人
    2021-01-21 14:45

    Looks like the Type values are of type [System.Data.DbType]. ConvertTo-Json converts the value names to the underlying numerical value of the DbType enum.

    You can override this behavior with the Select-Object statement:

    $Environment.Variables |Select-Object Name,Description,@{Name='Type';Expression={"$($_.Type)"}},Sensitivity,Value |ConvertTo-Json
    

    0 讨论(0)
提交回复
热议问题