Getting DELL Warranty Information (Part 2)

by Feb 25, 2015

PowerShell Version 2.0 and later

In a previous tip we illustrated how you can use a web service to retrieve warranty information for DELL computers. We received a lot of feedback, so before we add something new, here is the code that gets the warranty information:

$serial = '36GPL41'

$service = New-WebServiceProxy -Uri http://143.166.84.118/services/assetservice.asmx?WSDL
$guid = [Guid]::NewGuid()

$info = $service.GetAssetInformation($guid,'warrantycheck',$serial)
$Entitlements = $info.Entitlements 

$Entitlements

Now, if you tried and added $Entitlements to some textbox in a user interface, or output it as text, the result would not be what you wanted:

 
PS> "Your Entitlements: $Entitlements"
Your Entitlements: Microsoft.PowerShell.Commands.NewWebserviceProxy.Autogenerat
edTypes.WebServiceProxy1ervices_assetservice_asmx_WSDL.EntitlementData Microsof
t.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1erv
ices_assetservice_asmx_WSDL.EntitlementData Microsoft.PowerShell.Commands.NewWe
bserviceProxy.AutogeneratedTypes.WebServiceProxy1ervices_assetservice_asmx_WSDL
.EntitlementData

PS>  
 

This is because $Entitlements is an array of objects. When you display these as text, you want the PowerShell Extended Type System to process the objects, so run them through Out-String:

 
PS> $EntitlementsText = $Entitlements | Out-String

PS> "Your Entitlements: $EntitlementsText"
Your Entitlements: 

ServiceLevelCode        : TS
ServiceLevelDescription : P, ProSupport
Provider                : DELL
StartDate               : 23.03.2004 00:00:00
EndDate                 : 23.03.2007 00:00:00
DaysLeft                : 0
EntitlementType         : Expired

ServiceLevelCode        : ND
ServiceLevelDescription : C, NBD ONSITE
Provider                : UNY
StartDate               : 23.03.2005 00:00:00
EndDate                 : 23.03.2007 00:00:00
DaysLeft                : 0
EntitlementType         : Expired

ServiceLevelCode        : ND
ServiceLevelDescription : C, NBD ONSITE
Provider                : UNY
StartDate               : 23.03.2004 00:00:00
EndDate                 : 24.03.2005 00:00:00
DaysLeft                : 0
EntitlementType         : Expired
 

Twitter This Tip! ReTweet this Tip!