returning a value after doing a search in a text file RRS feed

  • Question

  • i need to be able to take a string, look in a txt file and if a match is found i need to return the contents of what is after the matched word.

    In the example i list below i need to find a match and then return the path (located after the comma

    Contents of text file:

    So for example the input value is Comp5, what i need returned is the path    \\server\share2

    I have the part of searching and finding the value, but i don't know how to have the other part returned.

    I can do this in either Powershell or as a VB script

    Monday, November 16, 2015 8:06 PM


  • $mappings = import-csv '\\path\to\your\file.csv'
    ($mappings | where-object { $_.Name -eq 'Comp5' } | select Path).Path
    This should do it.
    • Marked as answer by Joekos54 Monday, November 16, 2015 8:29 PM
    Monday, November 16, 2015 8:25 PM

All replies