Search code examples
powershellwgetinvoke-webrequest

Powershell: Invoke-WebRequest to Pull Expiry from website. Can't get to content


I have a ton of Dell Equipment that I need to check the warranty date on. I would like to use PowerShell to go the the Dell support page and just scrape the expiration date from the site, but I can't seem to get to the information.

#### Make sure that you are using TLS1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

#### Open request to Dell.com to get session info
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
Invoke-WebRequest -Uri https://www.dell.com/support/home -SessionVariable Session

#### Get page with serial number
$session.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"
$FullPage = (Invoke-WebRequest -Uri "https://www.dell.com/support/home/en-us/product-support/servicetag/9S2MVR2/overview" `
-WebSession $session `
-Headers @{
"method"="POST"
  "authority"="www.dell.com"
  "scheme"="https"
  "path"="/support/home/en-us/product-support/servicetag/14m1dh2/overview"
  "sec-ch-ua"="`" Not A;Brand`";v=`"99`", `"Chromium`";v=`"99`", `"Google Chrome`";v=`"99`""
  "sec-ch-ua-mobile"="?0"
  "sec-ch-ua-platform"="`"Windows`""
  "upgrade-insecure-requests"="1"
  "accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
  "sec-fetch-site"="none"
  "sec-fetch-mode"="navigate"
  "sec-fetch-user"="?1"
  "sec-fetch-dest"="document"
  "accept-encoding"="gzip, deflate, br"
  "accept-language"="en-US,en;q=0.9"
})

Solution

  • Have you considered using Dells warranty API? There's some great info here