Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Out-file formatting limitations?

Status
Not open for further replies.

flouie

MIS
Jul 18, 2002
7
0
0
US
Hello,

I'm a newbie to Powershell and I found this script to search for files containing SSN and it seems to work but my out-file seems to be unformatted and very hard to read.

Get-ChildItem -rec -exclude *.exe,*.dll |select-string "[0-9]{3}[-| ][0-9]{2}[-| ][0-9]{4}" |out-file C:\1.txt

Can someone tell me how do I get the out-file to only list the path and file name of the file containing SSN? I think the problem might be that the path to most of those files are very long and can be nested like 6 sub-folders deep.

Thanks in advance.
 
try this:

Get-ChildItem -rec -exclude *.exe,*.dll |select-string "[0-9]{3}[-| ][0-9]{2}[-| ][0-9]{4}" | fl Path | out-file C:\1.txt

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top