How to Automatically Download a Daily Excel File to OneDrive
Question details
The user needs to set up an automated daily process to log into a website, download an Excel file, and save a date-stamped copy directly to OneDrive or another cloud storage service.

- Product
- Excel
- Device & OS
- Windows
- Scenario
- Automating daily data reporting pipelines by fetching secure Excel files from a web source and routing them to a cloud synchronization folder without manual intervention.
- Observed behavior
- The goal is to eliminate manual daily logins and file downloads by implementing a reliable script or workflow to retrieve and save the file automatically.
Verify that you have the exact download URL, API endpoints (if the website provides them), and the necessary authentication credentials or access tokens required by the website.
Automate the Download using PowerShell and Task Scheduler
Create a PowerShell script using Invoke-WebRequest with authentication headers, then schedule it to run daily using Windows Task Scheduler.
PowerShell can handle HTTP requests and file manipulation seamlessly. By combining PowerShell's Invoke-WebRequest cmdlet with Windows Task Scheduler, you can fully automate the daily retrieval of files.
Open PowerShell ISE or Notepad. Write a script utilizing the 'Invoke-WebRequest' cmdlet. Include your authentication method (e.g., passing a PSCredential object, Bearer token, or session cookie in the Headers).
Use the 'Get-Date' command to generate a dynamic date string (e.g., 'yyyy-MM-dd') and append it to your destination filename. Set your '-OutFile' parameter to point directly to your local OneDrive sync folder path (e.g., 'C:\Users\YourUser\OneDrive\DailyReports\data_2023-10-25.xlsx').
Save the file with a '.ps1' extension. Run it manually in PowerShell to ensure the file downloads correctly and appears in your local OneDrive directory.
Open Windows Task Scheduler and click 'Create Basic Task'. Name the task and set the Trigger to 'Daily' with your preferred time.
Choose 'Start a Program'. In the Program/script box, type 'powershell.exe'. In the 'Add arguments' box, type '-ExecutionPolicy Bypass -File "C:\path\to\your\script.ps1"'. Save and enable the task.

Automate the Download using Microsoft Power Automate
Utilize Power Automate cloud flows to fetch the file via HTTP requests and save it directly to OneDrive without relying on local hardware.
Process Your Automated Excel Downloads with WPS Office
Once your automated processes download the daily Excel files to your OneDrive, you can seamlessly open, analyze, and format them using WPS Office. It provides a highly compatible and lightweight environment to manage all your daily spreadsheet tasks without heavy subscription fees.
- 1. Install WPS Office: Download and install the free WPS Office suite on your device.
- 2. Access the Downloaded Files: Open WPS Spreadsheets and navigate to your OneDrive folder to access the automatically downloaded daily files.
- 3. Analyze and Edit: Use built-in formulas, pivot tables, and data visualization tools to quickly process your daily reports.

Frequently Asked Questions
How do I handle complex website authentication in PowerShell?
If a website requires more than basic credentials, you can pass an API Access Token via the '-Headers' parameter in the Invoke-WebRequest cmdlet. If the site relies on browser sessions, you may need to capture a session cookie using '-SessionVariable' during a login request, and pass it to subsequent download requests.
Why does my scheduled PowerShell script fail to download the file when I am not logged in?
In Task Scheduler, ensure you select 'Run whether user is logged on or not' in the task properties. Also, check the 'Run with highest privileges' box. Note that you may need to enter your Windows password to save this setting.
What if the website does not have an API and requires visual clicking to download?
If a website lacks direct download URLs or APIs and relies heavily on JavaScript rendering and manual clicks, basic HTTP requests might fail. In this case, consider using browser automation tools like Selenium with PowerShell, or Robotic Process Automation (RPA) tools like Power Automate Desktop.




