Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I get Windows Powershell Get-ItemProperty to only show the property I want?
    text
    copied!<p>When using powershell, sometimes I want to only display for example the name or fullname of a file.<br> From what I can gather, the way to do this is by using <code>Get-ItemProperty</code> (alias of <code>gp</code>) and passing <code>-n fullname</code>, For example </p> <pre><code>PS C:\Dev&gt; gp . -n fullname </code></pre> <p>Notably I want to use this in longer scripts combined with <code>foreach</code> and <code>where</code>, and so on</p> <p>Powershell then displays the fullname, but it also displays a bunch of other stuff, as follows:</p> <pre><code>PSPath : Microsoft.PowerShell.Core\FileSystem::C:\Dev PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\ PSChildName : Dev PSDrive : C PSProvider : Microsoft.PowerShell.Core\FileSystem fullname : C:\Dev </code></pre> <p>My question is, how can I get powershell to <strong>only display the property I want</strong> (fullname) and not cruft the display up with all the other stuff. Is <code>Get-ItemProperty</code> even the right way to do this?</p> <h3>Update:</h3> <p>If I do this:</p> <pre><code>ls -r | ?{ $_.fullname -match "foo" } </code></pre> <p>This gives me a series of lists, one for each directory, showing all the 'foo' files in each directory. What I'd like to do is consolidate those multiple lists into one single list, and not show the <code>Mode</code>, <code>LastWriteTime</code>, <code>Length</code> or any other irrelevant stuff. If <code>Get-ItemProperty</code> is not the correct way to show those things, what is?</p>
 

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