Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Submit the form and get warranty details using Invoke-WebRequest

$
0
0

Hi Daniel,

Thank you for the reply. Your code works for me. I like the way you used '-join' operator to pass all argurments.
Finally to obtain the clean values I processed the object in the following way. If there is a more efficient way I will be greatfull to know.

Param
(
    [String]$SerialNumber = 'HU265BM18V',
    [String]$ProductNumber = 'H1P31AA'
)
 
$fields = @(
    'tmp_weCountry=us',
    "tmp_weSerial=$SerialNumber",
    "tmp_weProduct=$ProductNumber",
    "product=",
    "lc=en",
    "dlc=en"
    "cc=us"
)
 
$result=Invoke-WebRequest -Uri 'http://h10025.www1.hp.com/ewfrf/wc/weResults' -Method POST -Body ($fields -join '&')
$xmlresult = $result.AllElements | select -ExpandProperty innertext -Unique | ConvertTo-Xml
$WarrantyStatus = ($xmlresult.Objects.Object | where  `#text -Like "Warranty status*Warranty").'#text'.substring(15) 
$WarrantyEndDate = ($xmlresult.Objects.Object | where  `#text -Like "Warranty end date*(YYYY-MM-DD)").'#text'.substring(17,10)
Out-Default -InputObject "Warranty status: $WarrantyStatus. Warranty end date: $WarrantyEndDate"

This check is ok for single local machine. At work I have tousands of pcs already inventored with Serial Number.in database.
In the end I'like to be able to proces the requests in batches.
This page allows to submit up to 20 serial numbers and does not require the product number.
http://h20566.www2.hp.com/portal/site/hpsc/public/wc/home?ac.admitted=1405798585213.876444892.199480143
Since I am new in the forum, could you advise : should I open a new thread if I need further help ?

Thank you.
Tomasz


Viewing all articles
Browse latest Browse all 13067

Trending Articles