Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Struggling -ExpandProperty to Export-csv

$
0
0

All,

I'm learning PS and struggle on formatting when using -expandproperty.  I need assistance or guidance please. I am trying to Export-Csv below information. If you noticed the Hostname1 and Hostname2 have different "Key" and "Value" .  I want to export it to csv but it comes out different than what I expected.


$hostname.Results | select Name, Serial, Model -ExpandProperty  Tags | Export-Csv -Path "D:\temp\Exported.csv" -NoClobber -NoTypeInformation

above syntax  comes out like this. 

Name          Serial      Model        Key                    Value     
----          ------      -----        ---                    -----     
Hostname1 ABC1902KDXU BMWM3 EOL                    12/31/2021
Hostname1 ABC1902KDXU BMWM3 InService              8/1/2019  
Hostname1 ABC1902KDXU BMWM3 Depreciated            1/1/2025  
Hostname1 ABC1902KDXU BMWM3 EOS                    3/28/2021 
Hostname2 EFG2023J6HF BMWM3 EOS                    3/28/2021 
Hostname2 EFG2023J6HF BMWM3 EOL                    12/31/2021


How do I get it to export this format below?

I have been trying to look around the web and no luck for me. I've tried below but again no luck

Add-Member -Type Noteproperty

Format-Table




Viewing all articles
Browse latest Browse all 21975


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>