Author Posts

September 10, 2014 at 8:57 am

I am using import-csv, and one of the columns have a 3 word result set (Post University Online) in the $_.name column.

I would like to join all three words so there is no space using this syntax select-object @{n='Name';e={$_.name}}

any help with the method that may accomplish this would be greatly appreciated.

September 10, 2014 at 9:23 am

Give this a try:

Select-Object -Property @{name='Name';expression={$_.name -replace '\s'}}

September 10, 2014 at 9:30 am

perfect! thanks Mike

September 10, 2014 at 9:38 am

Mike one more ? i have a field that returns a date 09/09/2010 can i replace the "/" with a "-"

heres what i have so far

@{n='CreatedDate';e={$_.createddate.substring(0,9)}}
(im taking out the time)

September 10, 2014 at 9:42 am

i have the answer i figured it out

import-csv $ImportFile | select @{n='CreatedDate';e={$_.createddate.substring(0,9) -replace '/','-'}}

thanks mike for all your help