Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are two questions here.</p> <p>First, when you do <code>Select -Property Content</code>, what you are really telling powershell is "Please give me a new object with the selected properties for further processing". This works so you can continue with the pipeline. </p> <p>Second, if the pipeline ends, and there's nowhere else to put the data, formatting magic happens. For example <code>$doc | Select Content | format-table</code> will give the display you see now. What <code>format-table</code> receives however is a PSCustomObject with a dynamic type called <code>Selected.MyStuff.Document</code>. You could create magic type info for this, but since <code>Selected.MyStuff.Document</code> is dynamic, your format info would most likely be incorrect.</p> <p>Alternatively, instead of select, you can do something like <code>$doc.Content.ToString()</code> assuming you have only one $doc, or if you have a collection of <code>MyStuff.Document</code> objects, <code>$doc | % { $_.Content.ToString() }</code>. These both lose the header.</p> <p>If you want to format the entire MyStuff.Document object (no Select): <code>$doc | format-table</code>, you can use the following in a format.ps1xml file and magic happens. Note, I only implemented Format-Table for the MyStuff.Document type. You should be able to do something similar for your FormattedTextBlock.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;Configuration&gt; &lt;ViewDefinitions&gt; &lt;View&gt; &lt;Name&gt;MyStuff.Document&lt;/Name&gt; &lt;ViewSelectedBy&gt; &lt;TypeName&gt;MyStuff.Document&lt;/TypeName&gt; &lt;/ViewSelectedBy&gt; &lt;TableControl&gt; &lt;TableHeaders&gt; &lt;TableColumnHeader&gt; &lt;Label&gt;Name&lt;/Label&gt; &lt;/TableColumnHeader&gt; &lt;TableColumnHeader&gt; &lt;Label&gt;Content&lt;/Label&gt; &lt;/TableColumnHeader&gt; &lt;/TableHeaders&gt; &lt;TableRowEntries&gt; &lt;TableRowEntry&gt; &lt;TableColumnItems&gt; &lt;TableColumnItem&gt; &lt;Alignment&gt;Left&lt;/Alignment&gt; &lt;PropertyName&gt;Name&lt;/PropertyName&gt; &lt;/TableColumnItem&gt; &lt;TableColumnItem&gt; &lt;Alignment&gt;Left&lt;/Alignment&gt; &lt;ScriptBlock&gt;$_.Content.ToString()&lt;/ScriptBlock&gt; &lt;/TableColumnItem&gt; &lt;/TableColumnItems&gt; &lt;/TableRowEntry&gt; &lt;/TableRowEntries&gt; &lt;/TableControl&gt; &lt;/View&gt; &lt;/ViewDefinitions&gt; &lt;/Configuration&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload