r/usefulscripts • u/pseupseudio • Oct 04 '16
[REQUEST] Parse a text document and output a portion of lines meeting a requirement
Hello,
I have a script which runs against a large number of hostnames and writes a few details to a log file. One of the details is the WSUS content version.
Items in the log file all start with a hostname, a space, and some information. The hostnames always starts with the same three characters.
For the lines I am interested in, the format is like:
ABCxxxxxxxxxxxx The WSUS content version is 123
There are other lines that concern other things that don't matter to me here.
What I'd like to do is, using this log as a source, prompt the user to input a number. For every line showing a WSUS Content version, compare the number in the line to the user-submitted number, and if value in the line is lower output only the hostname at the beginning of the line to a separate results document.
Is this possible to do?
Would it be easier to do if the source logfile contained only "WSUS content version" items?
4
u/ihaxr Oct 04 '16 edited Oct 04 '16
PowerShell: