I am getting the firmware information of a server and I have it in a variable $t
but it's in the form of a string. I've (almost) successfully structured it into an object in order to export it into a CSV but there are a few kinks I need help with.
My main problem at the moment is that it seems like using ConvertFrom-String
changes things like 4.10
to 4
or 2017/04/06
to 4/6/2017 12:00:00 AM
. Is there any way around this?
Another issue is the ghost property P6
that shows up even though I am not explicitly asking for it. I deal with this by removing it afterwards but I wonder if I'm doing something wrong to spawn it.
PS C:\Users\user> $t.Output
system> Type Status Version BuildID ReleaseDate
---- ------ ------- ------- -----------
IMM2(Primary) Active 4.10 TCOO32C 2017/04/06
IMM2(Backup) Inactive 3.70 TCOO26H 2016/11/29
UEFI(Primary) Active 2.40 TCE130J 2017/04/11
UEFI(Backup) Inactive 2.40 TCE130J 2017/04/11
DSA Active 10.2 DSALA8N 2016/10/28
system>
PS C:\Users\user> $t.Output | ConvertFrom-String -PropertyNames 'Type', 'Status', 'Version', 'Build', 'ReleaseDate' | Select-Object -Index 2,4
Type : IMM2(Primary)
Status : Active
Version : 4
Build : TCOO32C
ReleaseDate : 4/6/2017 12:00:00 AM
P6 :
Type : UEFI(Primary)
Status : Active
Version : 2
Build : TCE130J
ReleaseDate : 4/11/2017 12:00:00 AM
P6 :
Thanks in advance.
This
12:00AM
and4.10
to4
stuff is happening becauseConvertFrom-String
is setting the type for the items, a DateTime for the date and an int for the status.To work around this you can use the
-TemplateContent
parameter to explicitly set the types you want, in this case strings.After replacing the hindering elements from the simulated output,
ConvertFrom-Csv
can do its job (the time still missing in your sample)