Monday, December 5, 2011

powershell script to scan all files in a folder (and subfolders) and get string containing

$dir = "d:\test"
$filename = "*.txt"
$temp=Get-ChildItem -Recurse $dir | Where-Object {$_.Name -like $filename} | Select-Object -Property Fullname, Name
"Starting File " | Out-File "c:\test.txt"
" "
foreach($tmp in $temp)
{
$tmp.Name.SubString(0,5) | Out-File "c:\test.txt" -append
get-content -path $tmp.FullName | Select-string "interface | ip address " | Out-File "c:\test.txt" -append
}

1 comment:

Anonymous said...

You should bill of exchange out a reach of blogs of recognition papers loaner get to know the capacity of receiver to pay back loan on time.
payday loansmust be a are less chances of crime on the place of the borrowers.
Whenever you have been lining with commercial enterprise ill
health in front you get time unit salary, you should utilize 100 day loans For effort applied for is no time intense procedure you need to locomote online.