Array not displaying as expected in report

by steveg at 2013-01-26 10:57:11

I have this snippet of code that works, but when i try to output it to an HTML I am not getting what i would expect

the code:

$Dell = New-WebServiceProxy -Uri http://xserv.dell.com/services/assetservice.asmx
$Warranty = $Dell.GetAssetInformation(([guid]::NewGuid()).Guid,"Dell warranty",(Get-WmiObject Win32_bios).SerialNumber)
$Entitlement = @($Warranty | Select-Object -ExpandProperty Entitlements |Format-Table ServiceLevelCode, StartDate, EndDate, DaysLeft, EntitlementType -auto)
$Entitlement


the result :

a user uploaded image
(in case the image doesn’t show)

ServiceLevelCode StartDate EndDate DaysLeft EntitlementType
ND 3/12/2012 12:00:00 AM 3/12/2014 12:00:00 AM 411 Active
ND 3/12/2012 12:00:00 AM 3/12/2014 12:00:00 AM 411 Active
ND 3/12/2011 12:00:00 AM 3/12/2012 12:00:00 AM 0 Expired


but when using Get-HTMLDetail "Dell Warranty Information" ($Entitlement) my report shows the following

a user uploaded image
(in case the image doesn’t show)

Microsoft.PowerShell.Commands.Internal.Format.FormatStartData.Microsft.PowerShell.Commands.Internal.Format.GroupStartData
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData.Microsft.PowerShell.Commands.Internal.Format.FormatEntryData
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData.Microsft.PowerShell.Commands.Internal.Format.GroupEndData
Microsoft.PowerShell.Commands.Internal.Format.FormatEndData


I am not sure why it is not showing the table data above.

Any help would be appreciated, I have been working on this little snippet for 2 days.
by ps_gregg at 2013-01-26 11:50:54
Hi Steve,

It looks like you are trying to get the results into an HTML format. If that is not correct, please let us know.

On line #3 after you have expanded the entitlements, you are left with "EntitlementData" objects which you are then piping to a Format-Table. This is great for Out- cmdlets (except out-grid) because it sends the objects to the formatting engine which converts objects to Formatted data to be used by the Out- cmdlets. However, the formatted data is not useable by the ConvertTo-HTML cmdlet. The ConvertTo-HTML cmdlet accepts objects and the "EntitlementData" objects work well being piped into it.

Try this as line #3 and see if that gets you where you wanted to go.

$Entitlement_HTML = $Warranty | Select-Object -ExpandProperty Entitlements | ConvertTo-Html -Head "Dell Warranty Information" -Property ServiceLevelCode, StartDate, EndDate, DaysLeft, EntitlementType
$Entitlement_HTML


I tested like this (below) and it appears to work:
$Dell = New-WebServiceProxy -Uri "http://xserv.dell.com/services/assetservice.asmx"
$Warranty = $Dell.GetAssetInformation(([guid]::NewGuid()).Guid,"Dell warranty","JZNZ12S")
$Entitlement_HTML = $Warranty | Select-Object -ExpandProperty Entitlements | ConvertTo-Html -Head "Dell Warranty Information" -Property ServiceLevelCode, StartDate, EndDate, DaysLeft, EntitlementType
$Entitlement_HTML

Cheers
-Gregg
by steveg at 2013-01-26 19:47:22
Thank you Gregg!!! That was the answer!

– Steve