Overview
FastBound has an API for downloading your latest bound book and maintains DownloadFastBoundBooks, a robust and flexible PowerShell script designed to automate the download of bound book PDF files from FastBound.
This script can download files from multiple FastBound accounts, securely add and remove accounts, and list accounts stored securely in your Secret Vault. Moreover, it has built-in error handling and can be scheduled to run daily to ensure compliance with ATF Ruling 2016-1.
Getting the Latest Version of PowerShell
The PowerShell script requires at least PowerShell version 7 to run correctly. Here’s how to install it:
-
Windows: Installing PowerShell on Windows
-
Ubuntu Linux: Installing PowerShell on Linux
How to Schedule the Script
Windows
On Windows, you can use Task Scheduler to run the script daily:
-
Open Task Scheduler and click “Create Basic Task…”
-
Name the task and provide a description.
-
Select “Daily” for the task trigger.
-
Set the Start time for when you want the script to run.
-
Select “Start a program” for the Action.
-
For “Program/script”, enter
powershell.exe
. In “Add arguments”, enter the path to the script like so:-File "C:pathtoDownloadFastBoundBook.ps1"
. -
Finish the creation process, and the task should be scheduled.
macOS
On MacOS, you can use cron jobs or launchd to schedule the script:
Cron Job:
-
Open Terminal.
-
Type
crontab -e
to open the cron table for editing. -
To run the script daily at a specific time, add a line like this:
0 12 * * * pwsh /path/to/DownloadFastBoundBook.ps1
, where0 12
specifies the script to run daily at noon.
Launchd:
You’ll need to create a plist file in ~/Library/LaunchAgents
. The structure is more complex than a cron job, but you can find more information in the launchd.plist man page.
Ubuntu Linux
On Linux, you can use cron jobs to schedule the script:
-
Open Terminal.
-
Type
crontab -e
to open the cron table for editing. -
To run the script daily at a specific time, add a line like this:
0 12 * * * pwsh /path/to/DownloadFastBoundBook.ps1
, where0 12
specifies the script to run daily at noon.
Always make your script executable (chmod +x /path/to/DownloadFastBoundBook.ps1
) and specify the full path to the PowerShell executable and your script in the cron job. Replace /path/to/DownloadFastBoundBook.ps1
with the actual path to your script.
Alternative Download Methods
Please be aware of the security risks when using commands like cURL. Hard-coding credentials directly into scripts or command lines can expose them to attackers or unauthorized personnel. You should look into more secure methods of storing credentials, such as environment variables or secure vault systems, especially in production environments.
cURL
url=$(curl -s -u FASTBOUND_ACCOUNT:FASTBOUND_API_KEY -H "X-AuditUser: user@example.com" -X POST https://cloud.fastbound.com/FASTBOUND_ACCOUNT/api/Downloads/BoundBook | grep -o '"url":"[^"]*' | sed 's/"url":"//') && curl -o FASTBOUND_ACCOUNT.pdf $url
Explanation:
-
url=$(curl -s -u FASTBOUND_ACCOUNT:FASTBOUND_API_KEY -H "X-AuditUser: user@example.com" -X POST https://cloud.fastbound.com/FASTBOUND_ACCOUNT/api/Downloads/BoundBook | grep -o '"url":"[^"]*' | sed 's/"url":"//')
stores the extracted bound book download URL in theurl
variable. -
&&
is used to execute the next command only if the previous command succeeds. -
curl -o FASTBOUND_ACCOUNT.pdf $url
cURLs the extracted URL and saves the output as “FASTBOUND_ACCOUNT.pdf”.
Please ensure you have curl
, grep
, and sed
installed on your system for this command to work correctly.