$sn = "CZC12068T4"
$country = "DK"
$body = "rows%5B0%5D.item.serialNumber=" + $sn + "&rows%5B0%5D.item.countryCode=" + $country + "&rows%5B1%5D.item.serialNumber=&rows%5B1%5D.item.countryCode=US&rows%5B2%5D.item.serialNumber=&rows%5B2%5D.item.countryCode=US&rows%5B3%5D.item.serialNumber=&rows%5B3%5D.item.countryCode=US&rows%5B4%5D.item.serialNumber=&rows%5B4%5D.item.countryCode=US&rows%5B5%5D.item.serialNumber=&rows%5B5%5D.item.countryCode=US&rows%5B6%5D.item.serialNumber=&rows%5B6%5D.item.countryCode=US&rows%5B7%5D.item.serialNumber=&rows%5B7%5D.item.countryCode=US&rows%5B8%5D.item.serialNumber=&rows%5B8%5D.item.countryCode=US&rows%5B9%5D.item.serialNumber=&rows%5B9%5D.item.countryCode=US&submitButton=Submit"
$r=Invoke-WebRequest -Uri ("http://h20564.www2.hp.com/hpsc/wc/public/find") -Method POST -Body $body
$ss = $r.RawContent.IndexOf("Wty: HP Support for Initial Setup")
# Extra run, in case of not found.
if($ss -lt 100) {
$r=Invoke-WebRequest -Uri ("http://h20564.www2.hp.com/hpsc/wc/public/find") -Method POST -Body $body
$ss = $r.RawContent.IndexOf("Wty: HP Support for Initial Setup")
}
if($ss -gt 100) {
$result = $r.rawcontent.substring($ss+42,20)
$end = $result.IndexOf("</")
$result = $result.Substring(0,$end)
get-date -Date $result -UFormat "%Y/%m/%d"
}
else {
$result = "not found"
$result
}
Hi,
I think that there is missing some thing at the end of your script. Could you post the missing part.
Thanks
Hi Claus
There is HTML tags in the code, that breakes the page.
Have fixed the code, an attached the powershell script file http://www.server1.dk/wp-content/uploads/2015/12/find_hp_warranty.zip
Kind regards
Henrik
Thanks, it is working now.
Regards
Claus