Link to home
Start Free TrialLog in
Avatar of jbla9028
jbla9028Flag for United States of America

asked on

Change Titles and Dates in a powershell generated CSV File

I am using powershell to generate a CSV File. I am using Quest ActiveRoles. Not sure if that matters but figured I'd mention it. I am exporting a listing of AD users. Another program is going to ingest this file but there's a few problems. The date field is not formatted correctly. I need to shave off the time from the date. I was told the application requires the header names to be specific values. Is there a way to reformat the headers to be called something different?  The script is below

get-qaduser -SearchRoot "OU=San Diego,OU=domain,DC=domain,DC=com","OU=New York,OU=domain,DC=domain,DC=com" -enabled -SizeLimit 0 -NotMemberOf "Test Accounts","Service Accounts","Hitachi-ID Exclude" | Select Email,FirstName,LastName,Department,WhenCreated  | Export-Csv 'C:\Scripts\Active Directory\InfoSec-UserExport.txt' -NoClobber -NoTypeInformation -Force

The output I get is

"Email","FirstName","LastName","Department","whenCreated"
"User1@domain.com","UserF1","UserL1l","Cashiering","9/8/2006 11:33:53 AM"
"User2@domain.com","UserF2","UserL2l","Cashiering","9/13/2006 11:50:59 AM"
"User3@domain.com","UserF3","UserL3l","Cashiering","12/6/2012 2:51:43 PM"


In the "When Created" field, I need to shave off the time and just include the date MM/DD/YYYY.

these titles need to change from:
"Email","FirstName","LastName","Department","whenCreated"
To:
"emailAddress","firstName","lastName","Department","whenCreated"


I'm assuming I need to do an import-csv but not sure exactly how to go about editing a particular field in a CSV in each record and also modify the column headers :(



Thank you in advance!
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jbla9028

ASKER

Perfect. Thank you!