Admitted newbie. I feel like this should be an easy one, and am certain I've even done this before, but in digging through the few scripts I've created, I can't find it...

I have a file called web.config at \\hostname\C$\Folder\Subfolder\Web.config. I need to find a specific line containing the string "license.log" and turn that one line into a variable. I know how to do it if I know what specific line number it's on, but this file can have different variations, so that line number can be different on any system.

I also need to be able to split the new variable when I get that far, so any tricks that need to be used to make that happen, I'll need help in adding that to my arsenal as well... I know how to split, but in case there's something specific I need when splitting from the text file, please say so!

Thanks. I've gone through the "Getting Started with Microsoft Powershell" through the Microsoft Virtual Academy. I've used the knowledge from that and a few questions in between to get a ton done in the last week... And I have every intention of doing more, but the boss put me on a project that he wants done asap.. Just one more piece to the puzzle and it's done... Then I can start studying more. And in reference to my other post and not posting my work – it's because everything I saw made absolutely no sense, so I really had nothing to show... My script is about a mile long, but that piece has stumped me. Once I'm done with lunch I'll try your suggestion – that's the last piece of the puzzle. Thanks for the input, I greatly appreciate it.

Author

Posts

The topic ‘Find Line In Text File And Turn Into Variable’ is closed to new replies.