Hello,
I've received help on my script to read a large file and using Get-Content and Select-String to create multiple files. My script works like a charm and looks like this:
$input = ".\Move_ClusterGroup_script.txt" #Create "A" Hosts move scripts. gc $input | select-string "HOSTA01" | out-file .\HOSTA01.txt gc $input | select-string "HOSTA02" | out-file .\HOSTA02.txt gc $input | select-string "HOSTA03" | out-file .\HOSTA03.txt gc $input | select-string "HOSTA04" | out-file .\HOSTA04.txt gc $input | select-string "HOSTA05" | out-file .\HOSTA05.txt #Create "B" Hosts move scripts. gc $input | select-string "HOSTB01" | out-file .\HOSTB01.txt gc $input | select-string "HOSTB02" | out-file .\HOSTB02.txt gc $input | select-string "HOSTB03" | out-file .\HOSTB03.txt gc $input | select-string "HOSTB04" | out-file .\HOSTB04.txt gc $input | select-string "HOSTB05" | out-file .\HOSTB05.txt
I'd like to expand on this script with the following requirement:
I'd like to write out at a maximum 20 records per file. When 20 are reached a new file will be created until all Select-String variables are satisified. So this would mean that my out-file would need to change and I would see out-file records like .\HostB01_1.txt, .\HostB01_2.txt, .\HostB01_3.txt...etc or something similar that satisify's the requirement.
Thank you.