Skip to content

Instantly share code, notes, and snippets.

@isa
Created February 9, 2012 03:09
Show Gist options
  • Save isa/1776924 to your computer and use it in GitHub Desktop.
Save isa/1776924 to your computer and use it in GitHub Desktop.
Powershell Awkwardness
C:\>$files = (gci -Recurse | Where { $_.Name -eq "some.file" }
C:\>$files.Length # prints 45
C:\>$files | %{ $_.FullName } # displays each file name properly
C:\>$files | %{ Get-Content $_ } # prints the first file content 45 times WTF?
@sunnyc7
Copy link

sunnyc7 commented Apr 30, 2012

This works as it is supposed.
Check if your $files is messed-up, or try opening powershell with -noprofile and check if the results are repeated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment