title: PowerShell input to function not work when pipeling input
body: <p>I have a powershell function that I inherited.  it works fine when using no input or providing a single server name as input.  </p>
  
  <p>Function works when running like this</p>
  
  <p><code>Get-DiskUtil</code> or </p>
  
  <pre><code>Get-DiskUtil computername
  </code></pre>
  
  <p>But if I try </p>
  
  <p><code>Get-Content c:\psfiles\servers.txt | Foreach-Object {Get-DiskUtil}</code>  (this give the output of the local machine three times if I have three server listed in servers.txt).</p>
  
  <p>or </p>
  
  <pre><code>Get-Content C:\psfiles\servers.txt | Get-DiskUtil
  </code></pre>
  
  <p>The result only gives the output of the local machine name and this error three times.</p>
  
  <p>Can someone tell me why Get-Content does not work and how I might go about fixing this?</p>
  
  <pre><code>computername=$_ : The term 'computername=$_' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a 
  path was included, verify that the path is correct and try again.
  At D:\Data\WindowsPowerShell\Modules\MyFunctions\Get-DiskUtil.ps1:4 char:10
  + if ($_) {computername=$_}
  +          ~~~~~~~~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (computername=$_:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
  </code></pre>
  
  <p>Get-DiskUtil:</p>
  
  <pre><code>Function Get-DiskUtil {
  Param([string] $computername=$env:computername)
  Process {
  if ($_) {computername=$_}
  gwmi win32_logicaldisk -fi "drivetype=3" -comp $computername |
  Select @{Name="Computername";Expression={$_.systemName}},
  DevicedID,
  @{Name="SizeGB";Expression={"{0:N2}" -f ($_.Size/1GB)}},
  @{Name="FreeGB";Expression={"{0:N2}" -f ($_.Freespace/1GB)}},
  @{Name="UsedGB";Expression={"{0:N2}" -f (($_.Size-$_.FreeSpace)/1GB)}},
  @{Name="PerFreeGB";Expression={"{0:P2}" -f ($_.Freespace/$_.size)}}
  }
  }
  </code></pre>