Array not displaying as expected in report

Welcome Forums General PowerShell Q&A Array not displaying as expected in report

Viewing 0 reply threads
  • Author
    Posts
    • #6006
      Participant
      Topics: 1562
      Replies: 0
      Points: 1
      Rank: Member

      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 <!-- m --><a class="postlink" href="http://xserv.dell.com/services/assetservice.asmx" rel="nofollow">http://xserv.dell.com/services/assetservice.asmx</a><!-- m --><br />    $Warranty = $Dell.GetAssetInformation&#40;&#40;[guid]::NewGuid&#40;&#41;&#41;.Guid,&quot;Dell warranty&quot;,&#40;Get-WmiObject Win32_bios&#41;.SerialNumber&#41;<br />    $Entitlement = @&#40;$Warranty | Select-Object -ExpandProperty Entitlements |Format-Table ServiceLevelCode, StartDate, EndDate, DaysLeft, EntitlementType -auto&#41;<br />    $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 &quot;Dell Warranty Information&quot; &#40;$Entitlement&#41; 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&quot;
      $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

Viewing 0 reply threads
  • The topic ‘Array not displaying as expected in report’ is closed to new replies.