Powershell - Retain the text of all Enum properties with ConvertTo-Json

前端 未结 2 915
情深已故
情深已故 2020-12-16 19:11

For \"Get-Msoldomain\" powershell command-let I get the below output (lets call it Output#1) where Name, Status and Authentication are the property names a

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 19:33

    Well, if you don't mind to take a little trip :) you can convert it to CSV which will force the string output, then re-convert it back from CSV to PS Object, then finally back to Json.

    Like this:

    Get-MsolDomain | ConvertTo-Csv | ConvertFrom-Csv | ConvertTo-Json
    
    • If you need to keep the original Types instead of converting it all to string see mklement0 helpful answer...

提交回复
热议问题