I am attempting a PowerShell exercise but am currently stuck and could use some help.
I am looking to produce a script that can take two tab delimited input files(datafile1.txt, datafile2.txt) and combine them into a single tab delimited txt file.
-- datafile1.txt
contains the following columns:
fielda
(username)fieldb
(date)
-- datafile2.txt contains the following columns:
fielda
(username)fieldc
(email)fieldd
(office)
This is what I have and I am able to output each file separately and even select just the start date from datafile1. But I can't figure out how to combine the two outputs into a single tab delimited text file. I feel like I'm so close but I'm too much of a pleb in my current state and about to pull my hair out. Thank you for any help provided.
I would like a single tab delimited text file that contains the following columns fielda
, fieldc
, fieldb
and fieldd
$columnNamesFile1 = "username", "Date"
$oldFile = Import-Csv "C:\Users\username\Downloads\New folder\datafile01.txt" -Delimiter "`t" -Header $columnNamesFile1 |
select "Start Date"
#$oldFile
$columnNamesFile2 = "username", "Email", "Office"
$datafile = Import-Csv "C:\Users\username\Downloads\New folder\datafile02.txt" -Delimiter "`t" -Header $columnNamesFile2 |
select "ID", "Email", "Office"
#$oldFile2
Everything I've tried prints the date at the bottom instead of creating a new column with the date in it.