I have been struggling to figure out how to use the "Out-File" from a textbox to a .txt and limit the amount of lines to that file. I have been able to do this the other way around with Get-content and using -totalcount 5 when sorting from a TextFile to Textbox.
I have this right now. I just do not know how to limit the amount of lines that get pulled from box $objOutputBox.Text to the file chines.txt. If I have say 20 lines that are names descending in $objOutputBox.Text and I only want 10 to pull over, this is what I'm trying to accomplish.
$objOutputBox.Text | Out-File C:\temp\PROD\chines.txt
Is there a easy way to set a line limit when using the Out-File in Poweshell? The other issue I was running into is that when I type line by line into the textbox and click_button to Out-File the lines they are placed descending to chines.txt. When I use Get-Content to grab some lines from another file (that is descending in the .txt) to fill the textbox(descending), then I use the Out-File to push those same lines to chines.txt they are placed as such below.
kvmlcops0263cdc kvmlcops0264bdc kvmlcops0264cdc kvmlcops0265bdc kvmlcops0265cdc
instead of
kvmlcops0263cdc
kvmlcops0264bdc
kvmlcops0264cdc
kvmlcops0265bdc
kvmlcops0265cdc
When I type the names into the box directly and use the Out-File they are placed into the txt as descending above. Is there a reason for this even though in the textbox they are descending?
Your help is highly desired and much appreciated.
Thanks,
Michael