Files
developer.sailpoint.com/docs/tools/sdk/powershell/index.mdx
2025-05-08 12:25:53 -04:00

220 lines
8.4 KiB
Plaintext

---
id: powershell-sdk
title: PowerShell SDK
pagination_label: PowerShell SDK
sidebar_label: PowerShell
sidebar_position: 3
sidebar_class_name: powershellsdk
keywords: ['powershell', 'sdk']
description: Easy ISC development in PowerShell.
slug: /tools/sdk/powershell
tags: ['SDK']
---
Read this guide to learn how to use the PowerShell SDK. The PowerShell SDK has some pre-built code examples you can use to learn how to build tools that can interact with IdentityNow.
## Requirements
You need the following to use the PowerShell SDK:
- PowerShell 6.2 or greater. To learn how to install, refer to [Installing PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4).
- Your tenant name in IdentityNow. To learn how to find it, refer to [Getting Started](/docs/api/getting-started#find-your-tenant-name). The SDK will use this tenant name to connect to your IdentityNow instance.
- A PAT with a client secret and ID. To learn how to create one in ISC, refer to [Personal Access Tokens](https://documentation.sailpoint.com/saas/help/common/api_keys.html#generating-a-personal-access-token). The SDK will use this PAT to authenticate with the SailPoint APIs.
## Setup
<details>
<summary>CLI assisted <em>(recommended)</em></summary>
The SailPoint CLI offers a few commands that will allow you to quickly get started with the PowerShell SDK. To learn how to install and use the SailPoint CLI, refer to [SailPoint CLI](https://developer.sailpoint.com/idn/tools/cli#get-the-cli).
Once the CLI is installed and configured, run this command to create a new PowerShell project with the PowerShell SDK:
```bash
sail sdk init powershell
```
Running the command create the structure for your project:
```text
|-- powershell-template
| |-- paginate.ps1
| |-- paginateAccounts.ps1
| |-- patchEntitlement.ps1
| |-- sdk.ps1
| |-- search.ps1
| |-- transform.ps1
```
Run this command to install the required dependencies:
```powershell
Install-Module -Name PSSailpoint
Install-Module -Name PSSailpoint.Beta
Install-Module -Name PSSailpoint.V3
Install-Module -Name PSSailpoint.V2024
```
The command installs the SailPoint PowerShell SDK module. You will be prompted to confirm that you want to install the module from 'PSGallery'. Enter "A" to say "Yes to All".
If you already have a version of the PowerShell SDK installed, you can install a new version side-by-side with it by adding the `-Force` parameter to the end of your `Install-Module` commmand:
```powershell
Install-Module -Name PSSailpoint -Force
Install-Module -Name PSSailpoint.Beta -Force
Install-Module -Name PSSailpoint.V3 -Force
Install-Module -Name PSSailpoint.V2024 -Force
```
To validate that the module is installed, run this command, `Get-Module -ListAvailable PSSailpoint`, and verify that the module is listed. Additionally, you can run this command, `Get-Command -Module PSSailpoint`, to see the available commands included in the module.
The SDK is now installed. To learn how to configure the SDK, refer to the [Configure section](#configure).
</details>
<details>
<summary>Manual installation</summary>
### Manually install the SDK
If access to the PowerShell Gallery isn't available, you can also install the PowerShell SDK manually.
:::caution
If you manually install the module on a machine without access to the PowerShell Gallery, you will also need to manually install updates to the SDK.
:::
Follow these steps to manually install the PowerShell module:
1. Download the source code zip from the most recent release on [GitHub](https://github.com/sailpoint-oss/powershell-sdk/releases).
2. Open the ZIP file, then open then folder labeled `powershell-sdk-x.x.x`, with the `x.x.x` representing the version you downloaded.
3. Extract the `PSSailpoint` module folder inside to one of the following locations:
- To install for the Current user: `C:\Users\<username>\Documents\WindowsPowerShell\Modules\PSSailpoint`
- To install for All users (requires Administrator privileges): `C:\Program Files\WindowsPowerShell\Modules\PSSailpoint`
4. Run `Import-Module PSSailpoint` to import the module into the current session.
5. To validate that the module is installed, run `Get-Module -ListAvailable PSSailpoint` and verify that the module is listed. Additionally, you can run `Get-Command -Module PSSailpoint` to see the module's available commands.
The SDK is now installed. To learn how to configure the SDK, refer to the [Configure section](#configure).
</details>
## Configure
You must provide configuration to the SDK so that it can authenticate to your SailPoint tenant and make API calls. To do so, you can use a configuration file, `config.json`, or environment variables.
### Configuration File
The SDK requires a configuration file to be named "config.json". Within the file, provide these key/value pairs: `ClientId`, `ClientSecret`, `BaseURL`.
<details>
<summary>CLI assisted <em>(recommended)</em></summary>
The SailPoint CLI offers a command to generate the config.json file with your currently configured CLI credentials.
```bash
sail sdk init config
```
If you have multiple environments configured with the CLI, you can pass an additional parameter to state the environment you wish to create a `config.json` for.
To pass an additional parameter that states the environment you want to configure, run this command:
```bash
sail sdk init config --env devrel
```
#### Example `config.json`
```json
{
"ClientId": "g0567b766b413b22c05c66e75d532f1b",
"ClientSecret": "cabd0e950a7230b63c1ff45be33fb22065b382b6251a73c61177a8bb5482fcc7",
"BaseURL": "https://[tenant].api.identitynow.com"
}
```
</details>
<details>
<summary>Manual configuration</summary>
Create a file named "config.json", and provide these key/value pairs: `ClientId`, `ClientSecret`, `BaseURL`.
#### Example `config.json`
```json
{
"ClientId": "g0567b766b413b22c05c66e75d532f1b",
"ClientSecret": "cabd0e950a7230b63c1ff45be33fb22065b382b6251a73c61177a8bb5482fcc7",
"BaseURL": "https://[tenant].api.identitynow.com"
}
```
</details>
:::warning
Please ensure this file is ignored in your version control system (ex. .gitignore for git)
:::
### Environment variable configuration
You can also store your configuration in environment variables.
To get your environment variables to persist across terminal sessions, add these exports to your shell profile, something like `~/.bash_profile`.
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
<Tabs>
<TabItem value="linux_mac" label="Linux/Mac" default>
```bash
export SAIL_BASE_URL=https://[tenant].api.identitynow.com
export SAIL_CLIENT_ID=[clientID]
export SAIL_CLIENT_SECRET=[clientSecret]
```
</TabItem>
<TabItem value="windows" label="Windows PowerShell">
```bash
$env:SAIL_BASE_URL=https://[tenant].api.identitynow.com
$env:SAIL_CLIENT_ID=[clientID]
$env:SAIL_CLIENT_SECRET=[clientSecret]
```
To get your environment variables to persist across PowerShell sessions, run these commands instead:
```powershell
[System.Environment]::SetEnvironmentVariable('SAIL_BASE_URL','https://[tenant].api.identitynow.com')
[System.Environment]::SetEnvironmentVariable('SAIL_CLIENT_ID','[clientID]')
[System.Environment]::SetEnvironmentVariable('SAIL_CLIENT_SECRET','[clientSecret]')
```
</TabItem>
</Tabs>
## Getting support
To get support for the PowerShell SDK, please see our GitHub page, https://github.com/sailpoint-oss/powershell-sdk.
To submit a bug report, please [click here](https://github.com/sailpoint-oss/powershell-sdk/issues/new?assignees=&labels=bug&template=bug-report.md).
To submit a feature request, please [click here](https://github.com/sailpoint-oss/powershell-sdk/issues/new?assignees=&labels=enhancement&template=feature-request.md)
## Contribute
Do you have an idea to help improve the PowerShell SDK? You can contribute directly!
Before you contribute, you must sign our [CLA](https://cla-assistant.io/sailpoint-oss/powershell-sdk) and read the [Contribution Guidelines](https://github.com/sailpoint-oss/developer.sailpoint.com/blob/main/CONTRIBUTING.md).
## Discuss
You can use this SDK to build new tools that extend your ISC platform and improve experiences across your organization. Use this guide to get started, and if you have questions, don't hesitate to reach out on the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss!
## Getting started
To get started using the SDK, refer to the [Getting Started Guide](./getting-started.md).