Powershell Call Pretty Console Quit C #

Powershell has pretty pretty modular modules for displaying objects, arrays, collections, dictionaries and tabular data.

Since Powershell is all .NET, I assume there is an assembly containing the logic for this.

Who can think of a way to call these powershell created from .NET:

I would suggest something like this:

Console.WriteLine(Powershell.DisplayObject(obj))
+3
source share
3 answers

Here's how you do it in V2:

PowerShell.Create().AddScript("get-Process |Out-String").Invoke()

The main thing is to call OUT-STRING.

Experiment! Enjoy it! Engage!

Jeffrey Sverver [MSFT] Windows Management Project Architect

+7
source

you can control the width of the output with | out-string -width 120.

+1

, , , .

: msdn PS blog

0
source

Source: https://habr.com/ru/post/1703827/


All Articles