PowerShell Invoke-WebRequest trouble with links RRS feed

  • Question

  • I'm trying to create a script which will parse an URL for a specific exe download link and download it. I'm doing this because the download link changes frequently. Below the code:

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    $path = "https://www.broadcom.com/support/security-center/definitions/download/detail?gid=sep14"
    $definitionPath = (Invoke-WebRequest $path).Links |
    Where-Object{$_.InnerText -like "*core15sdsv5i64.exe" -and $_.InnerText -notlike "*.jdb"} | 
    Select-Object -ExpandProperty href
    $Output = "C:\temp\virus_definition.exe" 
    $start_time = Get-Date
    Invoke-WebRequest -Uri $definitionPath -OutFile $Output
    I receive one error telling me that the argument "$definitionPath" is empty or null. Any ideas how can i fix that?


    Tuesday, March 10, 2020 2:30 PM

All replies

  • Your "Where-Object" filter is wrong. It returns nothing.

    Live long and prosper!


    Tuesday, March 10, 2020 3:38 PM
  • That web site does not return what you are after.  It is an Ajax page that will not load with WebRequest.  The JavaScript on the page must be executed to return the contents.

    Broadcom has an API that will allow you to retrieve updates and utilities from code.  Post in Broadcom forum for directions.


    • Edited by jrv Tuesday, March 10, 2020 8:10 PM
    Tuesday, March 10, 2020 8:10 PM