Performing API Operations Using PowerShell
Applies to PeerGFS v6.1.0 and later
Overview
You can access and manage the PeerGFS API using PowerShell, which provides a robust platform for automation and integration into existing workflows. This article explains how to run the PeerGFS PowerShell Toolkit, configure settings for automation, and use sample scripts to perform API operations. Whether you're creating custom scripts or automating routine tasks, these instructions will help you streamline your use of the PeerGFS API.
The PeerGFS PowerShell Toolkit is a set of specialized PowerShell commands and functions designed specifically for interacting with the PeerGFS system, leveraging PowerShell’s capabilities for automation. It is installed in the Peer Management Center directory, typically located in C:\Program Files\Peer Software\Peer Management Center\tools\powershell
.
Initializing the PeerGFS PowerShell Toolkit
Each time you open PowerShell, you must initialize the PeerGFS PowerShell Toolkit to load the necessary module for interacting with the PeerGFS API. To simplify this, we’ve provided the ConfigurePeerGFSToolkit.ps1
script, which you can run to initialize the toolkit.
Follow these steps to initialize the PeerGFS PowerShell Toolkit and load the necessary module for the PeerGFS API
Launch PowerShell on the PMC server and navigate to the following directory:
<PMC Installation Directory>\tools\powershell
.Run the following command in the PowerShell console to load the PowerShell module:
POWERSHELLPS C:\Program Files\Peer Software\Peer Management Center\tools\powershell> .\ConfigurePeerGFSToolkit.ps1
When you run the script, you will be prompted for user ID and password.
After loading the PowerShell module, you can begin using the API.
Creating and Using a Configuration File for PowerShell Initialization
When you’re ready to create custom scripts and automate tasks, it’s important to remember that you must initialize the PowerShell Toolkit each time you run PowerShell. The ConfigurePeerGFSToolkit.ps1 script loads the necessary PowerShell module, but to avoid entering your user credentials manually every time, you can use a configuration file (an .ini file) with the script. The .ini file stores your user credentials and ensures they are automatically applied when initializing PowerShell for scripting.
Follow these steps to create a configuration file that eliminates the need for manual input of credentials and server details, and initializes PowerShell automatically when running custom scripts:
Create the
settings.ini
file:Save the file in a secure location, such as an administrator's home directory.
If the script will be run by multiple users, save the file in the same directory as the
ConfigurePeerGFSToolkit.ps1
script.
Edit the
settings.ini
file, replacing the example values with your actual PMC credentials and server details:CODE[General] username=admin password=password [Network] address=127.0.0.1 port=8442
Run the
.\\ConfigurePeerGFSToolkit.ps1
script, passing thesettings.ini
file as the first parameter in the command. For example:CODE.\ConfigurePeerGFSToolkit.ps1 'C:\Users\Administrator\Documents\settings.ini'
This step initializes the PowerShell Toolkit with the credentials and server information from the configuration file. After this, the script can be run again without requiring manual input of credentials or server details.
PowerShell Script Examples
This section demonstrates how to use the PeerGFS API from a PowerShell client. These examples can be adapted to suit your workflow.
Use the examples as starting points to customize operations within your workflow.
Replace placeholder commands or parameters with values specific to your environment as needed.
Initialize the Toolkit and Show Available Commands
General Operations
Create a Job
Delete a Job
Start and Stop a Job
Release Quarantines
Related articles
- Check .pc-trash_bin date stored times for target protection
- Creating a Job Using Bash Scripting
- Creating a Job Using PowerShell Scripting
- Creating a Job Using Scripting
- Does the EOA of NetApp ONTAPI impact PeerGFS?
- Generating Client Code for PeerGFS API with Swagger.io
- Getting Started with the PeerGFS REST API
- Performing API Operations Using Bash
- Performing API Operations Using cURL
- Performing API Operations Using PowerShell
- Scripting Methods for API Operations
- Use PowerShell to connect to the PeerGFS API