---
updatedAt: 2025-08-14T13:33:00.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-central/llms.txt
---

# Export Customer Custom Property for Multiple Customers

```powershell PowerShell
# Define the customer custom property name to filter
$customPropertyName = "Enter Property Name Here"

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

    # Build the URI for the API endpoint
    $uri = "$apiUrl/api/customers"

    # 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"

    # 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"

    # 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 | Where-Object { $_.propertyName -eq $customPropertyName }

    foreach ($customProperty in $filteredCustomProperties) {
        $propertyData = [PSCustomObject]@{
            "Customer Name" = $customerName
            "Site Name"     = $null
            "Org Unit Id"   = $customerId
            "Property Name" = $customProperty.propertyName
            "Property ID"   = $customProperty.propertyId
            "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 | Where-Object { $_.propertyName -eq $customPropertyName }

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

            $combinedTable += $propertyData
        }
    }
}

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

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

```

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

# Define the Custom Property Name

<!-- powershell@1-2 -->

Set the $customPropertyName variable to specify the custom property name to filter.

# Function to Get Customers

<!-- powershell@4-24 -->

Define the NCentral-Customers function to retrieve customer information from the API using the provided URL and access token.

# Function to Get Sites

<!-- powershell@26-46 -->

Define the NCentral-Sites function to retrieve site information from the API using the provided URL and access token.

# Function to Get Customer Custom Properties

<!-- powershell@48-69 -->

Define the NCentral-CustomerCustomProperties function to retrieve custom properties of a customer from the API using the provided URL, access token, and customer ID

# Retrieve Customers and Sites



Call the NCentral-Customers function to get the list of customers.

Call the NCentral-Sites function to get the list of sites.

# Create Combined Table

<!-- powershell@75-129 -->

Initialize an empty array combinedTable to store the combined data.

Loop through each customer to retrieve and filter custom properties.

For each matching custom property, create a custom object with relevant details and add it to the combinedTable.

# Export to CSV

<!-- powershell@131-132 -->

Export the combinedTable to a CSV file at the specified path (C:\Temp\CustomerCustomProperty.csv).

# Display Combined Table (Optional)

<!-- powershell@134-135 -->

Display the combined table in a formatted table (commented out in the script).