'Powershell - Invoke-RestMethod to get all links

Trying to connect to webpage and return a list of all the file names listed there.

I wont include the whole code (to generate token etc), but using the below I can return the whole HTML doc.

$r = invoke-RestMethod $url -Headers @{Authorization="Bearer $bearerToken"} 

But I want to just get out the names of all the zip files, so in the below example I just want to return : 1_1_!!_DEV_ORG_HIER.zip

    <td>
      <a href="/xxxxxxx/rest/DEFAULT/20/file/deployments/1_1_%21%21_DEV_ORG_HIER.zip">1_1_!!_DEV_ORG_HIER.zip</a>
   </td>

Tried various things and plenty of googling, but no joy, I'm sure its something simple that is eluding me.

Any help greatly appreciated.



Solution 1:[1]

Managed to achieve what I wanted by using

Invoke-WebRequest rather than Invoke-RestMethod

As below.

$r = (Invoke-WebRequest $url -Headers @{Authorization="Bearer $bearerToken"}).links.innerhtml

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DanBot