I have this csv stored as
$CSV = ‘Employees.csv’
“Response Number”,“Submission Date”,“Submitted By”,“Last Edit Date”,“Last Edited By”,“Type of Form”,“Date Effective”,“Immediate Termination”,“First Name”,“Middle Initial/Name”,“Last Name”,“Additional Comments”,“Job Title”,“Title Changed?”,“Directly Reports to:”,“Job Status”,“Branch Number/Cost Center”,“Branch/Department”,“Now Directly Reports To:”,“Old Branch Number/Cost Center”,“Old Branch/Department”
“2480”,“2016-12-01 14:05:02”,“Katie Allen”,“”,“”,“New Hire”,“2016-12-27 00:00:00”,“”,“Person”,“”,“8”,“”,“Assistant Manager”,“”,“Mitzi Gipson”,“Full-Time”,“8606”,“Hattiesburg”,“”,“”,“”
“2476”,“2016-11-30 10:55:57”,“Brooke Smith”,“”,“”,“Deletion/Termination”,“2016-11-29 00:00:00”,“Yes”,“Person”,“”,“1”,“”,“Account Representative”,“”,“”,“”,“8027”,“Shelby”,“”,“”,“”
“2460”,“2016-11-28 10:31:54”,“Brooke Smith”,“”,“”,“Transfer”,“2016-12-05 00:00:00”,“”,“Person”,“”,“2”,“”,“Account Representative”,“No”,“”,“”,“5008”,“VA Beach”,“Angela Richardson-Brown”,“7204”,“Shreveport”
“2459”,“2016-11-28 10:30:43”,“Brooke Smith”,“”,“”,“Transfer”,“2016-11-28 00:00:00”,“”,“Person”,“”,“3”,“”,“Assistant Manager”,“Yes”,“”,“”,“7601”,“Mt Pleasant”,“Katherine Schmidt”,“7604”,“Middleton”
“2479”,“2016-12-01 08:49:14”,“Brooke Smith”,“”,“”,“Deletion/Termination”,“2016-12-01 00:00:00”,“Yes”,“Person”,“”,“4”,“No Longer coming on board”,“Account Representative”,“”,“”,“”,“3514”,“Elyria”,“”,“”,“”
“2453”,“2016-11-25 16:26:02”,“Becky Ratcliff”,“”,“”,“Title Change”,“2016-11-28 00:00:00”,“”,“Person”,“”,“5”,“”,“Assistant Manager”,“”,“”,“”,“8614”,“Tupelo, MS”,“”,“”,“”
“2451”,“2016-11-25 13:22:30”,“Caitlin Morgan”,“”,“”,“Title Change”,“2016-12-01 00:00:00”,“”,“Person”,“”,“6”,“”,“Assistant Manager”,“”,“”,“”,“7001”,“Albany”,“”,“”,“”
“2474”,“2016-11-30 09:40:19”,“Katie Allen”,“”,“”,“New Hire”,“2016-12-05 00:00:00”,“”,“Person”,“”,“9”,“”,“Assistant Manager”,“”,“Angie Doran”,“Full-Time”,“7305”,“Huntsville”,“”,“”,“”
“2465”,“2016-11-28 15:36:24”,“Brooke Smith”,“”,“”,“New Hire”,“2017-01-04 00:00:00”,“”,“Sara”,“”,“Lohse”,“”,“Marketing Intern”,“”,“Dara Diniso”,“Intern”,“1059”,“Marketing”,“”,“”,“”
“2452”,“2016-11-25 15:48:51”,“Caitlin Morgan”,“”,“”,“Title Change”,“2016-11-28 00:00:00”,“”,“Person”,“”,“7”,“all Owensboro employees should report to Kevin!”,“Branch Manager”,“”,“”,“”,“3803”,“Owensboro”,“”,“”,“”
I know how to change all “New Hires”, but how would I change just "one of the “New Hires” to “HQ New Hires”?
$Employee_CSV = Import-Csv '\\hqfs1\users\tantony\PowerShell\HRSecurityForms\Employees.csv'.ToString() $CSV = '\\hqfs1\users\tantony\PowerShell\HRSecurityForms\Employees.csv' $HQ_Department = "Executive","Central Auto Finance","Central Auto", "Auto", "Central Approval Office", "CAO", "Central Collections", "Collections", "Bankruptcy", "Legal", "Centralized Credit", "Central Credit", "Accounting", "Acquisitions", "Facilities", "Servicing Systems", "Servicing", "Audit", "Compliance", "Business Reporting", "Data", "Human Resources", "HR", "Information Technology", "IT", "Marketing", "Learning & Development", "Training", "Risk", "Baltimore Mortgage", "Mortgage" $Department = $Employee_CSV."Branch/Department" For($Queue=0; $Queue -lt $Employee_CSV.Length; $Queue++) { $Form_Type = ($Employee_CSV."Type of Form")[$Queue] if($HQ_Department -contains $Department[$Queue]) { #Write-Host $Department.GetValue($Queue), $Employee_CSV."Type of Form"[$Queue] Write-Host $Queue $Test = $Form_Type[$Queue] (Get-Content $CSV) -replace (("New Hire", "HQ New Hire")) | Set-Content $CSV -Force } }
Thanks,
Tony