Reputation: 137
I have code like this:
.
.
.
$s=$csv|select -ExpandProperty links
$m=$s|select hooks
$m
$m|Export-Csv C:\ooo.csv -NoTypeInformation
When I execute this code, it prints:
hooks
-----
@{href=https://yahoo.com/users/helloworld/hooks}
When I export this to CSV, it shows exactly like this, but I would like to take @{} out; I would like to show only like this:
href=https://yahoo.com/users/helloworld/hooks
How can I do that?
Upvotes: 0
Views: 686
Reputation: 2904
could be that hooks
is a collection which in that case must be converted to a string for export-csv
.
$m = ($csv | Select-Object -ExpandProperty links).hooks -join ';'
$m | Export-Csv .................
Upvotes: 1
Reputation: 76
usually this stuff can be gotten rid of as you import into a variable. you can use the below to replace it after. This says for each string in the variable m, replace @, }, and { with ""(nothing)
$m | %{$newvar += $_ -replace "@","" -replace "}","" -replace "{",""}
$newvar | export-csv -notypeinformation .....
Upvotes: 1