petben Posted May 11, 2022 Posted May 11, 2022 I have a simple Q for you. I want to add a column to an existing csv, then in that column add the same data to all cells. Can someone please send me a PowerShell idea. Thanks
ThomL Posted May 11, 2022 Posted May 11, 2022 (edited) Maybe something like this? Import-Csv File.csv | Select-[font=inherit]Object[/font] *,@{Name=[font=inherit]'New column'[/font];Expression={[font=inherit]'ValueForNewCol'[/font]}} | Export-Csv NewFile.csv -NoTypeInformation Edited May 11, 2022 by ThomL typo
petben Posted May 11, 2022 Author Posted May 11, 2022 sorry I dont understand the COLOR use. the csv is e.g. first,last pete,white james,cook I want to end up with first,last,role pete,white,staff james,cook,staff sounds easy. Thanks
ThomL Posted May 11, 2022 Posted May 11, 2022 (edited) sorry I dont understand the COLOR use. the csv is e.g. first,last pete,white james,cook I want to end up with first,last,role pete,white,staff james,cook,staff sounds easy. Thanks Had issues with posting the code to the forum, take another look at my previous post - I've updated it. EDIT! or here it is again with your column name and value added: Import-Csv File.csv | Select-[font=inherit]Object[/font] *,@{Name=[font=inherit]'[/font]role[font=inherit]'[/font];Expression={[font=inherit]'[/font]staff[font=inherit]'[/font]}} | Export-Csv NewFile.csv -NoTypeInformation Edited May 11, 2022 by ThomL 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now