title: windows powershell display the current variable in the pipeline during a for each loop
body: <p>Im deleting profiles using the get-wmi commandlet.  As the code goes through each delete command in the loop I would like to display which profile is being deleted.  I tried this:</p>
  
  <pre><code>$total = 0
  $count = 1
  foreach ($localpath in $dispaths)
  {$total = $total + 1}
  Foreach ($localpath in $dispaths) 
  {cls
  write-host "Deleting Profile: $_.localpath ($count of $total)"
  $count = $count + 1
  get-wmiobject -class win32_userprofile -computername $cname | where 
  {$_.localpath -eq $localpath.localpath} | foreach {$_.Delete()}
  }
  </code></pre>
  
  <p>but while the count works right, the display line shows literally:</p>
  
  <p>Deleting Profile: ./localpath (1 of 135) </p>
  
  <p>instead of displaying whatever the current string inside of the localpath variable is.  I tried removing the . from $._localpath but that just displayed something like this:</p>
  
  <p>Deleting Profile: (1 of 135)</p>
  
  <p>it doesnt display anything where the variable string should be.  Where am I going wrong?</p>