jbla9028
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","O U=New York,OU=domain,DC=domain,D C=com" -enabled -SizeLimit 0 -NotMemberOf "Test Accounts","Service Accounts","Hitachi-ID Exclude" | Select Email,FirstName,LastName,D epartment, WhenCreate d | Export-Csv 'C:\Scripts\Active Directory\InfoSec-UserExpo rt.txt' -NoClobber -NoTypeInformation -Force
The output I get is
"Email","FirstName","LastN ame","Depa rtment","w henCreated "
"User1@domain.com","UserF1 ","UserL1l ","Cashier ing","9/8/ 2006 11:33:53 AM"
"User2@domain.com","UserF2 ","UserL2l ","Cashier ing","9/13 /2006 11:50:59 AM"
"User3@domain.com","UserF3 ","UserL3l ","Cashier ing","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","LastN ame","Depa rtment","w henCreated "
To:
"emailAddress","firstName" ,"lastName ","Departm ent","when Created"
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!
get-qaduser -SearchRoot "OU=San Diego,OU=domain,DC=domain,
The output I get is
"Email","FirstName","LastN
"User1@domain.com","UserF1
"User2@domain.com","UserF2
"User3@domain.com","UserF3
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","LastN
To:
"emailAddress","firstName"
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER