Powershell has some pretty nifty formating modules for displaying objects, arrays, collections, dictionaries, and tabular data.
Since Powershell is all .NET, I'm assuming there is a Assembly containing the logic for this.
Who can come up with a way to call these powershell formating from .NET:
I'd imagine something like this:
Console.WriteLine(Powershell.DisplayObject(obj))
This is how you do it in V2:
PowerShell.Create().AddScript("get-Process |Out-String").Invoke()
The key thing is to call OUT-STRING.
Experiment! Enjoy! Engage!
Jeffrey Snover [MSFT] Windows Management Partner Architect
you might want to control the width of the output with | out-string -width 120 for instance.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.