The Get-HPCJob function is a Microsoft defined function that gets a list of jobs that match the specified criteria. It actually has a tabular look to it so import-csv will not work. $info = get-content input.txt foreach ($i in $info) exit (Note: at the moment OS is a static value) So if my Get-HPCJob command for today returns the following 4 jobs how do I add it in? crash_simulation test track 2 crash _simulation test track 3 I'm using get-content to read the file and I've tried split to seperate the data but I'm getting a lot of blank lines and I'm seperating things where I don't want to. My Input file looks something like this: Job Name OS Times Used - test job1 Windows 5 test job2 Windows 22 system size test job Windows 1 crash_simulation Windows 12 track 20000-beta ver 1.28 Windows 9 Now I need to be able to read this data in so that when I run the Get-HPCJob command for the day and find out what jobs we ran today and add them to the above input file.
Search for text in files powershell how to#
The problem is I'm not sure how to seperate the data on a line into its 3 seperate elements.
I have been asked to read in this file and then process each line so that I can either add to the number of times used if we rerun an existing job or add a whole new line if we run a new job. I was given a file that contains 3 columns of data (Job Name, OS, and Times Used). I'm still pretty new to scripting and powershell and I'm having problems processing an input file.