I have a text file that has one column of info, which was imported via CSV.
#TODO: Initialize Form Controls here
$Date = (Get-Date -Format "MM-dd-yyyy")
$DateTime = (Get-Date)
$Projects = Import-Csv c:\temp\pm_project.csv
#Show me the entire list of Projects
$Projects
number ------ FOAH18 FOAH278 FOAH313 PRJ0031905 PRJ0031909 PRJ0032045
These are chosen in a dropdown and placed in a text file. There are other choices they can make like administrative or other non project time.
$Matches = Get-Content "c:\temp\timesheet\$Date.txt"
#Show me all the entries in the text file
$Matches
11/06/2017 18:45:56 - This 15 minutes is dedicated to PROJECT ID FOAH18 11/06/2017 18:45:58 - This 15 minutes is dedicated to PROJECT ID FOAH278 11/06/2017 18:45:59 - This 15 minutes is dedicated to PROJECT ID FOAH313 11/06/2017 18:46:14 - This 15 minutes is dedicated to Administrative functions 11/06/2017 18:46:18 - This 15 minutes is dedicated to Sustain functions 11/06/2017 18:46:18 - This 15 minutes is dedicated to Sustain functions 11/06/2017 18:45:56 - This 15 minutes is dedicated to PROJECT ID PRJ0031905 11/06/2017 18:45:56 - This 15 minutes is dedicated to PROJECT ID PRJ0031909 11/06/2017 18:45:56 - This 15 minutes is dedicated to PROJECT ID PRJ0032045
I have a regex command that pulls the lines out that contain the Project ID number, which produces the below in to the pipeline.
#Show me only the lines in the test file that match the regex statement
$Matches = Select-String -Path "C:\temp\TimeSheet\$Date.txt" -Pattern '(?>FOAH|PRJ)\d{1,10}' -AllMatches
$Matches
$Matches.Count # This does show the proper amount of lines that match the regex command.
C:\temp\TimeSheet\11-06-2017.txt:1:11/06/2017 18:45:56 - This 15 minutes is dedicated to PROJECT ID FOAH18 C:\temp\TimeSheet\11-06-2017.txt:2:11/06/2017 18:45:58 - This 15 minutes is dedicated to PROJECT ID FOAH278 C:\temp\TimeSheet\11-06-2017.txt:3:11/06/2017 18:45:59 - This 15 minutes is dedicated to PROJECT ID FOAH313 C:\temp\TimeSheet\11-06-2017.txt:4:11/06/2017 18:46:00 - This 15 minutes is dedicated to PROJECT ID PRJ0031905 C:\temp\TimeSheet\11-06-2017.txt:5:11/06/2017 18:46:02 - This 15 minutes is dedicated to PROJECT ID PRJ0031909 C:\temp\TimeSheet\11-06-2017.txt:6:11/06/2017 18:46:03 - This 15 minutes is dedicated to PROJECT ID PRJ0032045
I did export the data from the pipeline and got the results below, but I don't know why I am getting the entire line instead of the regex filter.
Line 11/06/2017 18:45:56 - This 15 minutes is dedicated to PROJECT ID FOAH652 11/06/2017 18:45:58 - This 15 minutes is dedicated to PROJECT ID FOAH705 11/06/2017 18:45:59 - This 15 minutes is dedicated to PROJECT ID FOAH721 11/06/2017 18:46:00 - This 15 minutes is dedicated to PROJECT ID FOAH780 11/06/2017 18:46:02 - This 15 minutes is dedicated to PROJECT ID FOAH787 11/06/2017 18:46:03 - This 15 minutes is dedicated to PROJECT ID FOAH787
This is where I am stuck. My goals are as follows:
Put the project number only from all the regex hits in to an array. I only need the FOAH or PRJ number. Nothing else.
Get a count of how many of each are in this list. They will have several entries of the same projects throughout the day.
Get the total amount of minutes worked on each project. Each entry is 15 minutes.
Export this data in to a CSV file for further manipulation.