tags:

views:

22

answers:

2

I have a small script that searches through all files in a directory using something like this;

Get-ChildItem $location -recurse | select-string -pattern $pattern | select-object Path, FileName, LineNumber > C:\test.txt

The problem I have is that the Path gets enshortened, like this;

C:\program files\new folder\new f...

How can I get it to display the full path?

A: 

Export-Csv

made it possible, thanks to BartekB and denty on freenode's #powershell

cc0
+1  A: 

Just so it's clear why you saw the truncating behavior, the default formatter picked is Format-Table which divies up the current host width into three equally sized columns and if the data is wider than that it gets truncated. Another way of doing this:

gci $location -r | select-string $pattern | 
  Format-Table Path, FileName, LineNumber -Auto | 
  Out-File C:\test.txt -width 512
Keith Hill