Not quite sure if I understand what you mean - you need the sys_id of an attachment for both GET requests in the Attachment API. So if you don't need metadata, you can issue a GET to /now/attachment/{sys_id}/file right away. However, without metadata...
Happy to help!
The only downside is you'll end up with an XLSX with a content type of multipart/form-data. That doesn't seem to cause any problems though.
Here's another hint if you want to schedule the script - to store the credentials for your in...
Try this two-liner, just to see if you can get past the issue of the file getting corrupted:
$Uri = "https://[instance].service-now.com/api/now/attachment/file?table_name=sys_data_source&table_sys_id=[sys_id]&file_name=test.xlsx"
Invoke-WebRequest -M...