---
updatedAt: 2025-08-14T18:19:56.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-central/llms.txt
---

# NC Rest API - Export All Customer Custom Properties for Multiple Customers

```powershell PowerShell
##########################################################################################################################################
# You must be authenticated with API to run this script, you can use NC Rest API - Exchange JSON for Access Token.ps1 to authenticate    #
# This script will retrieve the value of all customer custom properties in N-central                                                     #
# This data is exported to C:\Temp\AllCustomerCustomProperties.csv, you can edit this on the Export-CSV line                             #
##########################################################################################################################################

# Function to get customers
function NCentral-Customers {
    param (
        [string]$apiUrl,
        [string]$accessToken
    )

    # Build the URI for the API endpoint
    $uri = "$apiUrl/api/customers?pageSize=-1"

    # Build the headers with the access token
    $headers = @{
        "Authorization" = "Bearer $accessToken"
    }

    # Send the GET request to retrieve customer information
    $response = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers

    # Return the array of customers from the response
    return $response.data
}

# Function to get sites
function NCentral-Sites {
    param (
        [string]$apiUrl,
        [string]$accessToken
    )

    # Build the URI for the API endpoint
    $uri = "$apiUrl/api/sites?pageSize=-1"

    # Build the headers with the access token
    $headers = @{
        "Authorization" = "Bearer $accessToken"
    }

    # Send the GET request to retrieve site information
    $response = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers

    # Return the array of sites from the response
    return $response.data
}

# Function to get custom properties of a device
function NCentral-CustomerCustomProperties {
    param (
        [string]$apiUrl,
        [string]$accessToken,
        [string]$customerId
    )

    # Build the URI for the API endpoint with the deviceId
    $uri = "$apiUrl/api/org-units/$customerId/custom-properties?pageSize=-1"

    # Build the headers with the access token
    $headers = @{
        "Authorization" = "Bearer $accessToken"
    }

    # Send the GET request to retrieve customer custom properties information
    $response = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers

    # Return the array of customer custom properties from the response
    return $response.data
}

# Retrieve customers and sites
$customers = NCentral-Customers -apiUrl $apiUrl -accessToken $accessToken
$sites = NCentral-Sites -apiUrl $apiUrl -accessToken $accessToken

# Create a combined table of customers, sites, and custom properties
$combinedTable = @()

foreach ($customer in $customers) {
    $customerId = $customer.customerId
    $customerName = $customer.customerName

    # Retrieve customer custom properties
    $CustomerCustomProperties = NCentral-CustomerCustomProperties -apiUrl $apiUrl -accessToken $accessToken -customerId $customerId

    # Filter for the specific custom property name
    $filteredCustomProperties = $CustomerCustomProperties

    foreach ($customProperty in $filteredCustomProperties) {
        $propertyData = [PSCustomObject]@{
            "Customer Name" = $customerName
            "Site Name"     = $null
            "Property Name" = $customProperty.propertyName
            "Property Type" = $customProperty.propertyType
            "Value"         = $customProperty.value
        }

        $combinedTable += $propertyData
    }

    # Process sites under the current customer
    $customerSites = $sites | Where-Object { $_.parentId -eq $customerId }

    foreach ($site in $customerSites) {
        $siteId = $site.siteID
        $siteName = $site.siteName

        # Retrieve site custom properties
        $SiteCustomProperties = NCentral-CustomerCustomProperties -apiUrl $apiUrl -accessToken $accessToken -customerId $siteId

        # Filter for the specific custom property name
        $filteredSiteCustomProperties = $SiteCustomProperties

        foreach ($customProperty in $filteredSiteCustomProperties) {
            $propertyData = [PSCustomObject]@{
                "Customer Name" = $customerName
                "Site Name"     = $siteName
                "Property Name" = $customProperty.propertyName
                "Property Type" = $customProperty.propertyType
                "Value"         = $customProperty.value
            }

            $combinedTable += $propertyData
        }
    }
}

# Export combined table to CSV
$combinedTable | Export-Csv -Path C:\Temp\AllCustomerCustomProperties.csv -NoTypeInformation

# Display combined table
$combinedTable | Format-Table -AutoSize

```

```json Response Example
{"success":true}
```

# Download PS1 file





# Authenticate using the NC Rest API - Exchange JSON for Access Token.ps1 script





# Run the PowerShell Script