change to only check one folder and record double
i run code on multiple folders , works. if check single share 2 differnt files on share it doubles output file. it's processing found files twice. want supply folder (parm) , 2 csv files combine single output file.
thanks.
function search-files{ param([string[]]$locations,[string[]]$searchfor, $appendto) begin { if(-not (test-path $appendto)){new-item $appendto -itemtype file -force} } process { foreach($location in $locations) { $files = get-childitem -path $location -filter $searchfor -recurse foreach($file in $files) { get-content -path $files.fullname | out-file $appendto -append } } } end{} } search-files -locations "\\servera\public\t1\usa\saleshist\",\\serverb\public\t2\usa\saleshist\ -searchfor "dodetail-cm.txt","somstr.txt" -appendto "\\virt1\saleshist_data_load_files\saleshdr.load.csv"
your get-content line in files section using $files.fullname instead of $file.fullname, should instead:
get-content -path $file.fullname | out-file $appendto -append
i hope post has helped!
Windows Server > Windows PowerShell
Comments
Post a Comment