---
title: "PowerShellSync"
description: "Export data from an external system with a PowerShell script that generates CSV files for Identity Manager, including prerequisites and settings."
sidebar_position: 210
---

# PowerShellSync

This connector exports data from an external system via a [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/overview) script.

This page is about [PowerShellSync](../references-packages/powershellsync.md).

![Package: Custom/PowerShellSync](/images/identitymanager/packages_powershellsync_v603.webp)

## Overview

PowerShell is a cross-platform task automation and configuration management framework, consisting of a command-line shell and scripting language. Unlike most shells which accept and return text, PowerShell is built on top of the .NET Common Language Runtime (CLR), and accepts and returns .NET objects. This fundamental change brings entirely new tools and methods for automation.

Data can be synchronized from any managed system by writing a PowerShell script that generates the relevant CSV files for Identity Manager. The PowerShellSync connector provides all the necessary tools for an easy integration of the script with Identity Manager's synchronization mechanisms.

When Identity Manager provides a native connector for a given system, for example the Active Directory connector, Netwrix Identity Manager (formerly Usercube)highly recommends using the native connector rather than this PowerShell connector.

## Prerequisites

Implementing this connector requires:

- making sure that the appropriate PowerShell executable is installed on the device hosting the agent: by default (`Edition` set to `Desktop`), the connector runs `powershell.exe` (Windows Powershell 5.1); when `Edition` is set to `Core`, the connector runs `pwsh` (PowerShell 7);
- knowledge of scripting in PowerShell 5.1 (Windows PowerShell, [see here requirements](https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/install/windows-powershell-system-requirements)) or PowerShell 7 (PowerShell Core, [see support lifecycle here](https://learn.microsoft.com/en-us/powershell/scripting/install/powershell-support-lifecycle)) depending on the selected `Edition`;
- making sure that the device hosting the agent has its execution policy properly configured to
execute the given PowerShell script;
- checking the targeted system's requirements (environment, libraries, etc.), as this connector is
meant to connect Identity Manager to a PowerShell-compatible system;
- writing and testing a PowerShell script (`.ps1`) according to Netwrix Identity Manager (formerly
Usercube)' guidelines below.

Windows PowerShell 5.1 is in maintenance mode. Netwrix recommends using `Edition: "Core"` (`pwsh`) for new connections where possible.

## Export

This connector executes a PowerShell script that generates one or several CSV files. These files are to be used during the synchronization of the data from the managed system targeted by the PowerShellSync connector.

The CSV files must be written to the `$OutputPath`.

The export is executed by a job from the UI, or via `Usercube-Export-Powershell.exe` in the command prompt.

### Configuration

This process is configured through a [Connection](../../../integrations/toolkit/xml-configuration/connectors/connection.md) in the UI and/or the XML configuration, and in the `*appsettings.agent.json* > Connections` section:

```json
*appsettings.agent.json*
{
  ...
  "Connections": {
    ...
    "<ConnectionIdentifier>": {
      ...
    }
  }
}
```

The identifier of the connection and thus the name of the subsection must:

- be unique.
- not begin with a digit.
- not contain `<`, `>`, `:`, `"`, `/`, `\`, `|`, `?`, `*` and `_`.

> For example:
>
> ```
> *appsettings.agent.json*
> {
>   ...
>   "Connections": {
>     ...
>     "PowerShellExport": {
>       "PowerShellScriptPath": "C:/identitymanagerDemo/Scripts/Export-CSV.ps1",
>     }
>   }
> }
> ```

##### Setting attributes

 | Name | Details |
 | --- | --- |
 | PowerShellScriptPath required | **Type** String **Description** Path of the PowerShell script (.ps1) to be executed. |
 | Edition optional | **Type** String **Description** Selects which PowerShell executable runs the script: `Desktop` (default) uses `powershell.exe` (Windows Powershell 5.1), `Core` uses `pwsh` (PowerShell 7). **Example** `"Edition": "Core"` |

### Write a script

Identity Manager provides a few variables to be used in the PowerShell script.

 | Name | Details |
 | --- | --- |
 | OutputPath | **Type** String **Description** Prefix of the path of the generated CSV file. **Info:** the synchronization process requires the generated CSV file to be located in a very specific location, with a specific name prefix. Hence the need for this predefined variable. **Value** [`<TempFolderPath>`](../../network-configuration/agent-configuration/appsettings.md)`/ExportOutput/<connectionIdentifier>_` **Example** In this example, if the temp folder is named `Temp` and the connection `PowerShellExport`, then the generated file is: `Temp/ExportOutput/PowerShellExport_users.csv`. ```generateCSV | Export-CSV ($OutputPath + "users.csv")` where`generateCSV``` is a generic PowerShell method that generates CSV files. |
 | IsIncremental | **Type** Boolean **Description** Variable to be used to provide a different behavior for complete and incremental synchronization. |

## Fulfill

There are no fulfill capabilities for this connector.

