Ocerra offers out of the box integration with many scripting languages using APIs. In this support article, we’re planning to use PowerShell to read invoices from Ocerra and store them on your local folder, including the original Invoice PDFs.
PowerShell is a standard windows scripting that allows us to call APIs. PowerShell is available on every Windows OS.
When you run a .ps1 PowerShell script for the first time, you might get the message saying: “.ps1 is not digitally signed. The script will not execute on the system.” To fix this issue:
1. Run PowerShell command as an administrator:
2. Copy-Paste this command, hit enter, enter Y to confirm:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
On the next step, we’re going to download the .ps1 script from Ocerra shared repository:
- Script file: https://raw.githubusercontent.com/Ocerra/Integration/master/PowerShell/ExportInvoices.ps1 - “save as type All files” and remove .txt extension to a folder on your computer i.e. C:/Ocerra/ExportInvoices.ps1
- Settings file: https://raw.githubusercontent.com/Ocerra/Integration/master/PowerShell/OcerraSettings.txt - save to the same folder C:/Ocerra/
Now we just open OcerraSettings.txt file in notepad and enter your Login and Password. You can create a separate API user in your company for better security:
We’re ready to execute it for the first time. You should be able to see the dark blue window for a moment with some progress results, and a new file appeared in this folder.
All your files are now stored in “yyyy-mm” folder, including original PDFs and CSV file with the list of invoices. The script will remember the last execution time and next time you run it, it will download changed / new invoices only: