title: Powershell : Use a Select-Object expression with a string
body: <p>For some scripts, i need to have an output composed of calculated properties.</p>
  
  <p>For example, for a list of ip addresses in ip.txt, i want to know if they respond to ping. So i try the following command:</p>
  
  <pre><code>Get-Content .\ip.txt | Select-Object $_,@{Name="ping?";Expression={Test-Connection $_ -Quiet -Count 1}}
  </code></pre>
  
  <p>But i get an error, regardless of what i do in the scriptblock expression.</p>
  
  <p>The error (in french, sorry):</p>
  
  <p><code>
  Select-Object : Paramètre Null. Le type attendu doit être l'un des suivants :  {System.String, System.Management.Automation.ScriptBlock}.
  Au niveau de ligne : 1 Caractère : 37
  + Get-Content .\ip.txt | Select-Object &lt;&lt;&lt;&lt;  $_,@{Name="ping?";Expression={Test-Connection $_  -Quiet -Count 1}}
      + CategoryInfo          : InvalidArgument: (:) [Select-Object], NotSupportedException
      + FullyQualifiedErrorId :   DictionaryKeyUnknownType,Microsoft.PowerShell.Commands.SelectObjectCommand
  </code></p>
  
  <p>I used the "calculated properties" in some scripts before, but with directories objects. Why it doesnt work with strings?</p>