Powershell add header/row to CSV -
i have piece of code generates csv of sharenames filer.
its tab-delimited csv , sharenames, no other details included.
i'd take output:
010 2012 comp 2012 comp plan team
and replace this:
\\<filer>\010 \\<filer>\2012 comp \\<filer>\2012 comp plan team
right have following:
$content = import-csv c:\temp\new.txt -delimiter "`t"
can use add-member command add in new property/values array? or going wrong way?
the comments have been great far, guys. forgot add point this. wondering how might add column csv? strictly filer names. i'm thinking of producing massive csv of share names , filer names. wanted know how add it?
if you've shown content of file there's no need bother import-csv
, use get-content
:
(get-content 'c:\temp\new.txt') -replace '^', '\\<filer>\'
the above produces merely array of strings. make csv 2 columns several things, instance transform string array array of objects same 2 properties:
(get-content 'c:\temp\new.txt') -replace '^', '\\<filer>\' | select @{n='path';e={$_}}, @{n='col2';e={...}}
or append ,something
strings , convert array csv:
(get-content 'c:\temp\new.txt') -replace '^', '\\<filer>\' -replace '$', ',...' | convertfrom-csv
Comments
Post a Comment