Skip to main content
Skip table of contents

Creating a Job Using PowerShell Scripting

Applies to PeerGFS v6.1.0 and later

Overview

This article expands on the workflow and high-level tasks described in Creating a Job Using Scripting.  It provides a detailed example of how to create a job using PowerShell and a job template.  This example demonstrates how to use a job template to pass user options on to the newly created job.

Task 1:  Configure NAS devices (if applicable)

Any NAS devices used for jobs need to be preconfigured in the Peer Management Center (PMC) user interface.

Step 1. Open the PMC, select Tools, and then select Open Preferences from the menu.

1-Create job-PowerShell.png

Step 2. In the NAS Configuration section, select a platform and configure the NAS devices.

2-Create job-PowerShell.png

For more detailed guidance on setting up NAS devices, see the PeerGFS User Guide.

Task 2:  Create a template job

Creating a template job is useful when using the API to create jobs regularly.  The template allows you to set parameters that are not default or available through the API.

To create the template job, run the following API command in a PowerShell terminal:

POWERSHELL
.\ConfigurePeerGFSToolkit.ps1 'C:\Users\Administrator\Documents\settings.ini'
New-PeerGFSJob -JobName TemplateJob -JobType FILE_REPLICATION

The JobType parameter can be set to FILE_COLLABORATION, SYNCHRONIZATION_ONLY, or FILE_REPLICATION.

image-20250518-184506.png

Once created, the job will appear in the user interface with a unique icon, indicating that it has no participants.

3-Create job-PowerShell.png

Task 3: Edit options to be passed on to new jobs

Step 1. Right-click the job and select Edit Job.

4-Create job-PowerShell.png

Step 2. Make the necessary changes to the job. In this example, we are adjusting the transfer size.

Edit General.png

Step 3. Click OK to save the changes.

Task 4: Create the job

Once the previous tasks are complete, production jobs can be created via the API without further UI interaction.  To create the production job, run the following command using PowerShell:

POWERSHELL
.\ConfigurePeerGFSToolkit.ps1 'C:\Users\Administrator\Documents\settings.ini'
New-PeerGFSJob -JobName WindowsRepla2 -RefJobId 101 -JobType FILE_REPLICATION

Where RefJobId is the job ID of the template job.

image-20250518-184434.png

If the job ID was not recorded, it can be retrieved by listing all jobs:

POWERSHELL
$jobs = Get-PeerGFSJobs
$jobs.jobs | ft
image-20250518-184901.png

For scripting purposes, the job ID can be stored in a variable:

POWERSHELL
$newJob = New-PeerGFSJob -JobName WindowsRepla2 -RefJobId 101 -JobType FILE_REPLICATION
$newJob.id
image-20250518-185336.png

Task 5: Add participants to the job

Now that the job is created, participants need to be added. A participant consists of an Agent and the volume, share, export, or folder to be replicated.

Step 1. List available storage devices

Run the following command to list available storage devices:

POWERSHELL
$storage = Get-PeerGFSStorage
$storage.storages | ft
image-20250519-085845.png

Storage volumes are returned as a JSON list, which can be processed logically or manually inspected. If volumes of a specific type are needed, the StorageDeviceType option can be used:

POWERSHELL
$storage = Get-PeerGFSStorage -StorageDeviceType DELL_POWERSCALE
$storage.storages | ft

Example output (filtered for DELL_POWERSCALE):

image-20250519-090041.png

Step 2. Add participants

Each participant must be added in turn. For replication jobs, there will only be one source participant. The following command adds the source participant:

POWERSHELL
Add-PeerGFSParticipant -JobId $newJob.id -StorageDeviceId WindowsAgent1:CLUSTER1 -Path \\CLUSTER1\Data
image-20250519-090249.png

For all other participants, the -SeedingTarget $true option must be added:

CODE
Add-PeerGFSParticipant -JobId $newJob.id -StorageDeviceId WindowsAgent2 -Path E:\Data -SeedingTarget $true

Once all participants have been successfully added to the job, you can check the job status by running the following command:

POWERSHELL
$job = Get-PeerGFSJobs -JobIds $newJob.id
$job.jobs
image-20250519-090600.png

Task 6: Start the job

Once the job has been fully configured, it needs to be started manually. To start the job, run the following command:

POWERSHELL
Start-PeerGFSJob -JobID $newJob.id

After executing the command, the job will be in a running state. You can confirm this by checking the UI, where the job will now appear as running.

image-20250519-083612.png
6-Create job-PowerShell.png
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.