A Comprehensive Guide: Setup, Integration, and Task Scheduling with PowerShell
This guide will walk you through the process of deploying the Synthesize SDK using the PowerShell terminal in Windows. It will cover steps to clone the repository, set up the environment, run commands, and schedule tasks.
Prerequisites
- PowerShell 7.0 or higher
- Git installed on your system, or download the .zip repository from GitHub
Step 1: Obtain the Repository
Option 1: Clone the Repository with Git
Open the PowerShell terminal and navigate to the directory where you want to clone the repository. Run the following command:
Option 2: Download the .zip Repository
If you don't have Git installed, you can download the .zip repository from GitHub:
- Visit https://github.com/meetgradient/Synthesize-SDK-PS
- Click on the green "Code" button and choose "Download ZIP"
- Extract the contents of the .zip file to your desired directory
Step 2: Change Directory
Navigate to the cloned or extracted repository by running:
cd Synthesize-SDK-PS
Step 3: Set Up the Environment
Create a .env file to store the API keys and other required variables. Use a text editor to create a new file named ".env" in the root directory of the project. Add the following contents:
VENDOR_API_KEY=your_vendor_api_key
GRADIENT_TOKEN=your_gradient_token
Replace "your_synthesize_api_key", "your_vendor_api_key", and "your_gradient_token" with the respective keys and token obtained from the Synthesize platform and your vendor.
Step 4: Load Environment Variables
In the PowerShell terminal, run the following command to load the environment variables:
Step 5: Update Integration Status
Run the 'update-status' command to update the status of the custom integration to pending:
Step 6: Sync Usage
Once the custom integration is configured, run the 'sync-usage' command to sync usage for the mapped customers and services:
Scheduling Recurring Tasks in PowerShell
To schedule a recurring task in PowerShell, you can use the built-in Task Scheduler. Follow these steps:
-
Open Task Scheduler by searching for it in the Start menu.
-
Click on "Create Task" in the right-hand pane.
-
In the "General" tab, give your task a name and description.
-
Switch to the "Triggers" tab and click on "New" to create a new trigger. Choose the schedule settings as desired (e.g., daily, weekly, or monthly).
-
Switch to the "Actions" tab and click on "New" to create a new action. In the "Program/script" field, input the path to your PowerShell executable (usually "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"). In the "Add arguments" field, input the following command:
Replace "path\to" with the actual path to the "sync-usage.ps1" script in your Synthesize-SDK-PS directory.
- Click "OK" to save the action, and then click "OK" again to save the task. The task will now run according to the schedule you specified.
By following these steps, you can set up the Synthesize SDK, integrate it with your vendor, and schedule tasks using the PowerShell terminal in Windows.