This article provides simple to use steps to demonstrate Symantec Endpoint Security products usage with PowerShell 5.1. These steps can also be used to validate that the Rest API for products listed below is functioning as expected.
Contained within each Product folder are two or more scripts. Generally each products has a script with Authentication, auth or token in the name. This script should be run first to generate an access token which is then used in the other scripts in that folder.
Set-ExecutionPolicy -ExecutionPolicy ByPass -Scope Process
Example: cd "<drive>:\full\path\to\folder"
Below are detailed steps that give more context that may help in some scenarios.
Download the Endpoint_products_REST_API_scripts.zip file attached to this article (scroll to the bottom of the page) to a Windows computer. Extract the .zip file. Inside the .zip file are various folders, each one representing a specific product.
Open PowerShell and confirm the version by running this command:
$PSVersionTable
This will print out a table, reference the PSVersion row. Most Windows operating systems have version 5.1.x by default. Newer versions may have Version 7. These scripts were validated against 5.1.x but will work on version 7, although you may see warnings.
Next, run this command:
Set-ExecutionPolicy -ExecutionPolicy ByPass -Scope Process
This command will bypass any defined PowerShell execution policy defined for the PowerShell window currently open. Depending on your environment's ExecutionPolicy, this may need to be run every time a new Powershell window is opened.
In the PowerShell window, navigate to folder where you saved the scripts to. This can be done a few ways. Typing "cd" then the path (like in a cmd prompt) works. You can also type:
Set-Location C:\path\to\scripts
The easiest may be using File Explorer. right click on the folder that contains the scripts and choose "Open in Terminal" which opens a PowerShell window at that path. Don't forget to run the execution policy if you choose this method.
Finally, run one of the scripts by typing in the script name. Example using the SEPM script "SEPM-Authentication.ps1"
SEPM-Authentication.ps1
Each script will prompt for some sort of information needed to complete the Rest API call. Depending on the product and script, you may be asked to provide one or more of the following:
After entering the required information, the API will return information.
Below is a list of all the individual scripts in theEndpoint_products_REST_API_scripts.zip file and a brief description of each.
These scripts should be used with Data Center Security version 6.9.3 and older.
These scripts should be used with Data Center Security version 6.9.3 and older.
Invoke-RestMethod : Unable to connect to the remote server
This is caused being unable to connect to the product's Rest API. Check the IP/port you entered into the script. Also check general network connectivity to the IP and port. PowerShell's Test-NetConnection is helpful here.
Test-NetConnection -ComputerName <name or IP> -Port <port>
The steps and scripts attached in this article serve as examples of Symantec Endpoint Security products Rest API usage with PowerShell. Support can assist with confirming Rest API functionality and verifying individual API calls are working as designed. Assistance with custom scripting is outside the scope of standard support.