Powershell:调用 WebRequest 以从网站中提取过期信息。无法访问内容

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

我有大量戴尔设备需要查看保修日期。我想使用 PowerShell 访问 Dell 支持页面并从网站上抓取到期日期,但我似乎无法获取信息。

#### 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"
})

您是否考虑过使用戴尔保修API?有一些很棒的信息 here