I have a project where I need to search a folder and based upon passed in parms to the script do a lookup in each file for those values and copy that file to a new file. I used the following to search a folder:
Get-ChildItem -Path '\\srv1\archive\' | Select-String -Pattern "793383355"
Now my requirement have changed.
1) check 1st record in file does it start with ISA if so, then use the 1st passed in value to script to lookup TP then use 2nd passed in value to lookup on Date.
--If not found go get next file in folder.
-- If found then read the 2nd record in file and look for "record type" which will be the 3rd passed in value to script.
-- If found then copy the file to another folder \\srv1\search\captures
-- If all 3 parms not located in file then skip to next file in folder.
example script called:
xxsrc_folder_search.ps1 -hdr "ISA" -date "21/03/10" -rectype "PO"
It would be great if script prompted user for those 3 inputs values. The -hdr and -date will always be on the first record in file
if found. The -rectype will always be on the 2nd record in file if found
any help would be greatly appreciated.