> For the complete documentation index, see [llms.txt](https://docs.keeper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keeper.io/user-guides/de/import-records-1/import-from-cyberark.md).

# Import von CyberArk PACLI

Importieren Sie Konten aus CyberArk-Safes mithilfe von Microsoft PowerShell und dem CyberArk-PACLI-Dienstprogramm.

<figure><img src="https://914511346-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSGVtOTYUIkVBoYtFvK%2Fuploads%2Fp1rub66SO3Rvd4Fod9Hh%2FImport-Keeper-Cyberark.jpg?alt=media&#x26;token=2dd2db77-c695-4c77-bcda-68974a31bdf0" alt=""><figcaption></figcaption></figure>

CyberArk verfügt über eine Befehlszeilenschnittstelle namens PACLI, die direkt mit dem CyberArk Vault kommuniziert. Sie arbeitet mit „Dateien", die in „Safes" im Vault gespeichert sind. Sie kann CyberArk-*Account*-Daten exportieren, die CyberArk-Clients wie *PrivateArk* und *Password Vault Web Access (PVWA)* als *Dateien* in *Safes* speichern.

Die folgenden Anweisungen verwenden ein PowerShell-Skript, das mit PACLI alle Dateien exportiert, die einem Muster entsprechen. Mit dem Standardmuster „\*" werden alle Dateien aus dem Safe exportiert. Dabei werden für jede Datei der Benutzername, die Adresse und das Passwort extrahiert; das Skript kann jedoch bei Bedarf so konfiguriert werden, dass weitere Felder extrahiert werden. Da das Skript die exportierten Dateien als Objekte bereitstellt, wird anschließend mit ConvertTo-CSV eine Umwandlung in das CSV-Format (Comma-separated Value) vorgenommen, um sie in Keeper zu importieren.

## Voraussetzungen <a href="#prerequisites" id="prerequisites"></a>

Für die Verwendung des folgenden Skripts sind drei externe Komponenten erforderlich:

1. CyberArk PACLI
2. Eine Vault.ini-Konfigurationsdatei
3. Eine User.ini-Datei mit Zugangsdaten

### CyberArk PACLI <a href="#cyberark-pacli" id="cyberark-pacli"></a>

Die PACLI steht auf der Website des CyberArk Marketplace zum Download bereit. Es handelt sich um eine ZIP-Datei, die die Binärdatei `PACLI.exe` sowie einige zugehörige Dateien enthält. Das Skript erwartet den Pfad des *Verzeichnisses*, das die Binärdatei enthält.

### Vault.ini <a href="#vaultini" id="vaultini"></a>

Die Datei vault.ini enthält die Parameter, die PACLI benötigt, um den Vault zu finden und sich dort anzumelden. Beispiel:

```ini
VAULT=CAMainVault
ADDRESS=10.11.12.13
PREAUTHSECUREDSESSION=YES
TRUSTSSC=YES
```

Der Wert für VAULT kann in der Regel auf „CAMainVault" belassen werden.

ADDRESS ist der Hostname oder die IP-Adresse des CyberArk-Vault-Servers.

Die Einstellungen PREAUTHSECUREDSESSION und TRUSTSSC sind erforderlich, wenn sich der anmeldende Benutzer über LDAP (Active Directory) oder RADIUS authentifiziert. Andernfalls können sie weggelassen werden.

### User.ini <a href="#userini" id="userini"></a>

Die Datei User.ini liegt im INI-Format vor. Sie wird jedoch mit dem Tool `CreateCredFile.exe` erzeugt, das CyberArk zusammen mit einigen seiner Komponenten bereitstellt. Beispiel: Erzeugen einer user.ini für *Myuser* in der Active-Directory-Domäne *CORP*:

```powershell
CreateCredFile.exe User.ini Password /Username Myuser /Password "MyPassw0rd!" /ExternalAuth /OSUsername CORP\Myusername
```

Die neueste Version des PACLI-ZIP-Archivs enthält dieses Tool. Wird es mit dem Parameter `/?` ausgeführt, werden die weiteren Optionen erläutert, die in anderen Authentifizierungsszenarien nützlich sind.

## Export <a href="#export" id="export"></a>

Fügen Sie Folgendes in eine Datei ein, die auf *.ps1* endet, z. B. *Export-CyberArkSafeFiles.ps1*:

```powershell
<#
.SYNOPSIS
Exports 'files', i.e., CyberArk Account passwords from a CyberArk Safe using PACLI.

.DESCRIPTION
Uses CyberArk's PACLI command to export files from a CyberArk Safe.
It retrieves files, their categories, and contents and exports an object for each.
It uses filepattern=* to get all files in the safe by default.
The default categories are 'Address' and 'UserName'.
#>
param (
    # The name of the 'Vault' in CyberArk, e.g., 'CAMainVault'
    [Parameter(Mandatory = $true)][string]$VaultName,
    # The name of the 'Safe' in CyberArk
    [Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$SafeName,
    # The CyberArk log on user (must match credentials in the User.ini)
    [Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$Username,
    # The path to the PACLI directory containing PACLI.exe
    [Parameter(Mandatory = $true)]
    [ValidateScript({ Test-Path -PathType Leaf (Join-Path $_ 'PACLI.exe') })]
    [string]$PACLIPath,
    # Arguments `findfiles` uses to generate the list of files to export
    [string[]]$FindFilesArguments = 'filepattern=*',
    # The categories to export from the files
    [Parameter()][string[]]$Categories = @('Address', 'UserName'),
    # A CyberArk Vault.ini file
    [Parameter()][ValidateScript({ Test-Path $_ -PathType Leaf })]
    [string]$VaultIniPath = 'Vault.ini',
    # A CyberArk User.ini (or .cred) file as generated by CreateCredFile.exe
    [Parameter()][ValidateScript({ Test-Path $_ -PathType Leaf })]
    [string]$UserIniPath = 'User.ini',
    # The folder in the safe to export files from--most use 'Root'
    [string]$FolderName = 'Root',
    # The session ID to use for the underlying PACLI commands
    [Parameter()][ValidateNotNullOrEmpty()][string]$SessionId,
    # ErrorAction for retrievefile errors
    [Parameter()][ValidateSet('Stop', 'Continue', 'SilentlyContinue')]
    [string]$PACLIErrorAction = 'Continue'
)

$PACLI = Join-Path $PACLIPath 'PACLI.exe' -Resolve

function Invoke-PACLI {
    param (
        [Parameter(Mandatory = $True)][string]$Command,
        [Parameter(ValueFromRemainingArguments)][string[]]$Arguments
    )
    $Executable = ".\{0}" -f (Split-Path -Leaf $PACLI)
    $CommandLine = "$Executable $Command $($Arguments -join ' ')"
    try {
        Push-Location $(Split-Path -Parent $PACLI) -StackName 'PACLI'
        $Output = (& $Executable $Command $Arguments 2>$null)
        if ($LastExitCode -eq 0) {
            $Output
        }
        else {
            switch ($PACLIErrorAction) {
                'Continue' {
                    Write-Error "'$CommandLine' exited with code $LastExitCode"
                }
                'Stop' { throw "'$CommandLine' exited with code $LastExitCode" }
            }
        }
    }
    finally {
        Pop-Location -StackName 'PACLI'
    }
}

Invoke-PACLI init

$PACLIDefaults = "vault=$VaultName", "user=$Username", "safe=$SafeName", 
"folder=$FolderName"
if ($SessionId) {
    $PACLIDefaults += "sessionId=$SessionId"
}
Invoke-PACLI default @PACLIDefaults
Invoke-PACLI definefromfile vault=$VaultName parmfile=(Resolve-Path $VaultIniPath) |
Out-Null
Invoke-PACLI logon logonfile=(Resolve-Path $UserIniPath) | Out-Null
Invoke-PACLI opensafe | Out-Null

try {
    # Create a temporary file to store the file contents during processing
    $tempFile = [IO.Path]::GetTempFileName()
    # Split the tempFile path into the folder and the filename for 'retrievefile'
    $localFolder = Split-Path $tempFile
    $localFile = Split-Path -Leaf $tempFile

    # Get the list of files in the safe
    Invoke-PACLI findfiles $FindFilesArguments 'output(name)' |
    Where-Object { $_.Trim() -ne '' } |
    ForEach-Object {
        $file = @{ Name = $_ }
        # Retrieve the file and store the contents (the password) in the file object
        Invoke-PACLI retrievefile file=$_ localfolder=$localFolder localfile=$localFile
        if ($LastExitCode -ne 0) { return }
        $file.Password = (Get-Content $tempFile).TrimEnd([Char]0) # Can be null-padded
        # Get the list of categories for the file as a quoted CSV string
        Invoke-PACLI listfilecategories file=$_ 'output(all,enclose)' |
        ForEach-Object {
            # Get the category name and value and strip the quotes
            $category = ($_ -split ',' | ForEach-Object { $_.Trim('"') })[0..1]
            # Add the category to the file object if it is on the list
            if ($category[0] -in $Categories) {
                $file[$category[0]] = $category[1]
            }
        }
        [PSCustomObject]$file
    }
}
finally {
    Remove-Item -Path $tempFile -Force
}

Invoke-PACLI closesafe vault=$VaultName user=$Username safe=$SafeName | Out-Null
Invoke-PACLI logoff vault=$VaultName user=$Username | Out-Null
Invoke-PACLI term | Out-Null
```

Entpacken Sie die PACLI.zip in dasselbe Verzeichnis wie das Skript oder in ein Unterverzeichnis davon.

Öffnen Sie PowerShell und wechseln Sie in das Verzeichnis, das das Skript enthält.

Führen Sie das Skript aus und leiten Sie die Ausgabe an [Export-CSV](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/export-csv) weiter:

```powershell
.\Export-CyberArkSafeFiles.ps1 CAMainVault MySafe Myuser .\PACLI-Rls-v11.5.3 |
Export-CSV Records.csv -Delimiter "`t" -Encoding utf8 -NoHeader -UseQuotes Never
```

Die Verwendung von Tabulatorzeichen statt Kommas, die UTF-8-Kodierung, der Verzicht auf eine Kopfzeile und das Weglassen von Anführungszeichen bei den Daten helfen Keeper dabei, die Daten korrekt zu importieren.

### Transformation <a href="#transformation" id="transformation"></a>

PowerShell kann die Daten nicht nur als CSV formatieren, sondern auch weiter transformieren. Dieses fortgeschrittenere Beispiel erstellt das Feld „login", indem es die Felder Username und Address kombiniert, und verwendet es zusätzlich als Feld „title".

```powershell
.\Export-CyberArkSafeFiles.ps1 CAMainVault MySafe Myuser .\PACLI-Rls-v11.5.3 |
Select-Object @{l='Folder';e={$_.Name -replace "-$($_.Address)-$($_.Username)", '' }},
 @{l='Login';e={'{0}@{1}' -f $_.Username, $_.Address}}, Password |
Select-Object Folder, @{l='Title';e={$_.Login}}, Login, Password |
Export-Csv Records.csv -Delimiter "`t" -Encoding utf8 -NoHeader -UseQuotes Never
```

## Import <a href="#import" id="import"></a>

Folgen Sie den Anweisungen zum Import von Textdateien (.csv, .xls, .tsv) [hier](/user-guides/de/import-records-1/import-a-.csv-file.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.keeper.io/user-guides/de/import-records-1/import-from-cyberark.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
