Announcement

Collapse
No announcement yet.

Filtering Findstr results

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Filtering Findstr results

    I am trying to extract the last word of a findstr results query

    The command I run
    Code:
    findstr /i %1 x:\itlogs\who_when.txt | findstr /i %2
    the results I get
    Code:
    12/02/2018 10:17:58 SmithS Steve Smith B0K9VY1
    13/02/2018 09:29:13 SmithS Steve Smith B0K9VY1
    What i need from the results is that last word B0K9VY1 so i can run SCCM RemoteControl $computername

    (it will *always* be the last word on the last line of the results from my findstr query)

  • #2
    Code:
    For /F "tokens=*" %%a in ('findstr /i %1 x:\itlogs\who_when.txt ^| findstr /i %2') do for %%b in (%%a) do set machine=%%b
    SCCM RemoteControl %machine%

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X