---
title: Generate O2C Demo Data - PowerShell Script and Use Cases
description: Use the PowerShell script to generate realistic 7-step Order-to-Cash demo data with BPM metadata, multi-format messages, and Repository Binding for integration landscape visualization in Nodinite.
---

# Generate O2C Demo Data - PowerShell Script

**Automate realistic Order-to-Cash demo data generation** with 7 integration steps, multi-format support, and [BPM][] metadata. This PowerShell 7 script generates complete order flows as :Nodinite: [Log Events][JSON formatted Log Event] for testing, visualization, and integration landscape demonstrations.

* ✅ Generate 7-step O2C flows (Steps 0-6) with 90% probabilistic progression  
* ✅ Multi-format messages (JSON, XML, CSV, PSV) across different [Systems][]  
* ✅ [Repository Binding][] and BPM metadata included for integration landscape visualization  
* ✅ 100 orders generating ~1,070 [Log Events][Log Event] in about 3 seconds  

![PowerShell 7 running Generate-O2C-Demo-Data.ps1 with -DryRun: the 100 orders generated, the first order's 14 Log Events printed as JSON with the Correlation ID in ApplicationInterchangeId and the Repository Binding in the Context, and the summary of the run, animated walkthrough (7.12)][1]  
*Animated walkthrough: in the folder with the script, run `.\Generate-O2C-Demo-Data.ps1 -DryRun` in PowerShell 7. The script generates all 100 orders in memory and prints only the first one: its 14 Log Events as JSON, `ORD-10001` with the Correlation ID in `ApplicationInterchangeId`, and the [Repository Binding][] in the Context. The summary ends the run; nothing was exported or sent.*  

## :fa-diagram-project: Understanding the Data Generator

<div class="mermaid">
graph LR
    Script["fa:fa-terminal Generate-O2C-Demo-Data.ps1"] -->|"-DryRun"| Console["fa:fa-display Console preview"]
    Script -->|"-ExportToFile"| File["fa:fa-file-code JSON file"]
    File --> LogAPI["fa:fa-cloud-arrow-down Log API"]
    LogAPI --> Repo["fa:fa-sitemap Repository Model and BPM"]
    style Script fill:#9E59BB
    style Console fill:#2678BD
    style File fill:#2678BD
    style LogAPI fill:#3F827B
    style Repo fill:#93d16d
</div>

*The script (purple) previews or exports the Log Events (blue); posted to the [Log API][LogAPI] (teal), they build the [Repository Model][] and the BPM (green).*

### Quick Facts

* **Script**: Copy the source from [Generate O2C Demo Data Script][Generate-O2C-Demo-Data-Script] and save it as `Generate-O2C-Demo-Data.ps1`. It needs **PowerShell 7** (`pwsh`); Windows PowerShell 5.1 and PowerShell ISE can't run it
* **Default**: 100 orders, base time 06:00 UTC, output to the console or a file. The script never calls the [Log API][LogAPI]; you post the exported events yourself
* **Data**: Each order generates up to 14 events (2 per step, SequenceNo 1-14) and spans about 4-36 minutes of simulated time (30-300 seconds per step)
* **First Order**: Always completes all 7 steps for guaranteed demo content; every other order completes at least 2 steps. It is always `CUST-001` with one Demo Widget (USD 99.95), the order the step pages show
* **Business data**: The other orders rotate through six customers and pick a product and a quantity, so the payloads differ; see [Customers, products, and grouping](#fa-users-customers-products-and-grouping)
* **Log Agent**: The script logs as [Log Agent][Log Agents] `5` (`$LOG_AGENT_VALUE_ID`), with [Endpoint Type][Endpoint Types] `60`

>[!NOTE]
>`5` is also the default [Log Agent][Log Agents] for [Azure Logic Apps][] logging. In an environment that already logs Logic Apps, or that other demos share, change `$LOG_AGENT_VALUE_ID` in your copy of the script to an id no other Log Agent uses, so the demo events stay separate.

### Parameters

|Parameter|Type|Default|Description|
|---|---|---|---|
|`LogApiUrl`|string|`https://localhost:40002/LogAPI/api/LogEvent`|:Nodinite: [Log API][LogAPI] endpoint; in v7 the endpoint is `https://{host}:{port}/LogAPI/api/LogEvent` ([Log using REST][]). Not used yet: see the note below|
|`ApiKey`|string|`YOUR_API_KEY_HERE`|API authentication key. Not used yet|
|`OutputFile`|string|`C:\Temp\O2C-Demo-Data.json`|Output file path for export|
|`OrderCount`|int|`100`|Number of orders to generate|
|`ExportToFile`|switch|`$false`|Export to a JSON file instead of calling the API|
|`DryRun`|switch|`$false`|Preview mode (first order only)|

>[!NOTE]
>The script doesn't call the Log API. Without `-ExportToFile` it prints *Would call Log API at …* and the event count, and stops. Write the events to a file with `-ExportToFile`, then post them, for example with the loop in [Post the Exported Events to the Log API](#post-the-exported-events-to-the-log-api).

## :fa-users: Customers, products, and grouping

Order *n* gets customer number ((*n* - 1) mod 6) + 1, so every run of six orders or more has all six customers. All names are fictitious.

|Customer|Name|City|ZIP|Country|Warehouse|Carrier|
|---|---|---|---|---|---|---|
|`CUST-001`|Contoso Corporation|Springfield, IL|62701|US|WH-01|Standard Courier|
|`CUST-002`|Fabrikam Inc.|Springfield, IL|62704|US|WH-01|Standard Courier|
|`CUST-003`|Northwind Traders|Seattle, WA|98101|US|WH-02|Pacific Express|
|`CUST-004`|Adventure Works|Seattle, WA|98109|US|WH-02|Pacific Express|
|`CUST-005`|Tailspin Toys|Stockholm|111 51|SE|WH-03|Nordic Freight|
|`CUST-006`|Wide World Importers|Gothenburg|411 36|SE|WH-03|Nordic Freight|

Each order has one order line: `SKU-DEMO-001` Demo Widget (USD 99.95), `SKU-DEMO-002` Demo Gadget (USD 249.00), or `SKU-DEMO-003` Demo Sprocket (USD 12.50), with a quantity of 1 to 5. The total follows, and an order of USD 500 or more gets the planning priority `HIGH` instead of `NORMAL`. The customer, ship-to address, warehouse, carrier, product, quantity, and total appear in the payloads of every step, and the `CustomerId`, `CustomerName`, and `OrderAmount` Context Properties follow the order. The flow, the [Services][], and the [Log Statuses][Log Status Codes] are the same for every order.

### Group the orders by place and customer

The Order Received body carries a `shipTo` object, so a [Log View][Log Views] can group the orders on up to four fields:

1. Create [Search Fields][] on `O2C.Order.Received/1.0` with [JSON Path][] expressions: `$.shipTo.country`, `$.shipTo.city`, `$.shipTo.zip`, and `$.customer.name`. Turn on suppress warnings, because older events have no `shipTo`, and reindex.
2. Create a Log View with **Data to search** limited to that [Message Type][Message Types], and on the [Grouping tab][Log View Grouping Tab] group by Country, City, ZIP, and Customer Name.
3. Search today's run. Each group is one combination of the four values, shown together in the group header, such as *US · Springfield · 62701 · Contoso Corporation*: six groups for the six customers. The groups don't nest; see [Group on several fields][Grouping - Several Fields] for a walkthrough.

## :fa-list-check: Use Cases and Execution

### Use Case 1: Quick Preview (Dry Run)

**Scenario**: Test the script locally and review the generated structure before full execution.

```powershell
.\Generate-O2C-Demo-Data.ps1 -DryRun
```

**Output**: Generates all orders, then prints the first 14 Log Events, which is the first order (it always completes all 7 steps). **Result**: 14 events displayed as a preview; nothing is exported or sent. The walkthrough at the top of this page shows this run.

### Use Case 2: Export Demo Dataset to File

**Scenario**: Generate the complete dataset and export it to a JSON file for testing or documentation.

```powershell
.\Generate-O2C-Demo-Data.ps1 -OrderCount 100 -ExportToFile -OutputFile "C:\Temp\O2C-Demo.json"
```

**Output**: JSON file with ~1,070 events. **Use**: [Post the events to the Log API](#post-the-exported-events-to-the-log-api), import them into Postman, or analyze BPM flows.

### Use Case 3: Small Batch (Development/Testing)

**Scenario**: Generate fewer orders for rapid testing cycles.

```powershell
.\Generate-O2C-Demo-Data.ps1 -OrderCount 10 -ExportToFile -OutputFile "C:\Temp\O2C-10.json"
```

**Output**: 10 orders (about 110 events; the run below gave 126). **Use**: Quick validation, local testing, CI/CD pipeline smoke tests.

![PowerShell 7 exporting 10 orders to the file O2C-10.json, a loop posting the file's 126 Log Events, then the Log View Contoso: Orders searched Today with the new orders, the first row ORD-10010's last step in red with Log Status -1337, animated walkthrough (7.12)][2]  
*Animated walkthrough: export 10 orders to a file, post the file's events with the loop in [Post the Exported Events to the Log API](#post-the-exported-events-to-the-log-api), and search the **Contoso: Orders** [Log View][Log Views] with **Today**. The new orders are dated from 06:00 UTC today; the red row is the last step of an incomplete order, with Log Status `-1337`.*  

### Use Case 4: Large Batch (Production Demo)

**Scenario**: Generate a comprehensive dataset for BPM visualization and an integration landscape demo.

```powershell
.\Generate-O2C-Demo-Data.ps1 -OrderCount 500 -ExportToFile -OutputFile "C:\Temp\O2C-500.json"
```

**Output**: 500 orders (~5,300 events). **Use**: Demonstrate integration scale, BPM visualization, and landscape topology.

### Use Case 5: Direct API Integration

**Scenario**: Send events directly to the :Nodinite: Log API endpoint.

```powershell
.\Generate-O2C-Demo-Data.ps1 `
  -LogApiUrl "https://nodinite.contoso.com:40002/LogAPI/api/LogEvent" `
  -ApiKey "your-api-key-here" `
  -OrderCount 100
```

**Output**: The script prints the target URL and the event count instead of posting the events; export them and post them with the loop in [Post the Exported Events to the Log API](#post-the-exported-events-to-the-log-api). **Use**: Live BPM visualization, real-time integration landscape updates, demonstrations.

## :fa-star: Key Features

* [7-Step O2C Process][O2C Process]: Steps 0-6 with 90% progression probability per step. The first order always completes all steps.
* **Multi-Format Support**: JSON (Steps 0, 3, 6), XML (Steps 1, 4), CSV (Step 2), PSV (Step 5) - demonstrates format diversity.
* **Correlation ID Format**: `{PREFIX}-{YYYYMMDD}-{HHMM}-{SEQUENCE}` (e.g., `PIC-20251024-0930-0001`) for end-to-end traceability. The `HHMM` is the time the script generates the order.
* **BPM Metadata**: Every event's Repository Binding names its Service. Receive events from Step 1 on add `ExternalServiceRelations` (the previous step's Send Service), and Send events add `InternalServiceRelations` (the same step's Receive Service). Only the business event of each step carries the BPM data; the forwarding event (`O2C.Forwarding/1.0`) has none.
* **Realistic Timing**: Base time 06:00 UTC on the day you run the script, 0.5-5 minute increments per step, 1-4 seconds between a step's Receive and Send events, 2-10 minute order spacing, processing times 5-50 ms (Receive) and 40-300 ms (Send).
* **Error Marking**: The last Send event of an incomplete order gets Log Status `-1337`; all other events get `0`.

>[!IMPORTANT]
>Run the script before 06:00 UTC and its events are dated later than now. Search them with **Today**, which covers the whole day.

### Expected Output

* **Log Events**: ~1,070 events from 100 orders (about 10.7 per order on average; the random progression gives a spread, one run gave 1,166), generated in about 3 seconds
* **Full Happy-Path Orders**: ~54 (order 1, plus 99 × 0.9⁶ ≈ 53)
* **Incomplete Orders**: ~46
* **First Order**: Always completes all 7 steps (100% complete for testing)

### Data Volume

* **Each Log Event**: ~1-2 KB
* **Each Repository Binding**: ~3-5 KB (includes BPM metadata)

## :fa-file-code: Output Examples

### Export Format

When you export to file with `-ExportToFile`, the output is a JSON array of Log Events. Each event includes the Repository Binding with BPM metadata:

```json
[
  {
    "LogAgentValueId": 5,
    "EndPointName": "Portal-OrderReceived-Drop",
    "EndPointUri": "C:\\Integration\\Portal\\Orders\\In",
    "EndPointDirection": 0,
    "EndPointTypeId": 60,
    "OriginalMessageTypeName": "O2C.Order.Received/1.0",
    "LogDateTime": "2025-10-14T06:02:15.0000000Z",
    "EventDirection": 17,
    "SequenceNo": 1,
    "EventNumber": 1,
    "LogText": "Order Received from Customer",
    "ApplicationInterchangeId": "PIC-20251014-0915-0001",
    "LogStatus": 0,
    "ProcessName": "O2C-Order-Reception",
    "Context": {
      "FileName": "ORD-10001-order-received-from-customer.json",
      "OrderNumber": "ORD-10001",
      "CustomerId": "CUST-001",
      "CustomerName": "Contoso Corporation",
      "OrderAmount": "99.95",
      "ExtendedProperties/1.0#RepositoryBinding": "{\"Name\":\"Standard Transport Contract\",\"Service\":{\"Name\":\"INT1337-RCV-Order-Incoming\",\"Direction\":\"Receive\",\"System\":{\"Name\":\"Portal\"},\"Integration\":{\"Name\":\"INT1337 - Order-to-Cash\"},\"BPMs\":[{\"Name\":\"INT1337 - Order-to-Cash Flow\",\"ArtifactRenaming\":\"Order Received\",\"Domain\":{\"Name\":\"Sales\",\"Index\":0},\"Step\":0,\"ServiceRelations\":[...]}]}}"
    },
    "Body": "eyJiYXRjaElkIjoiYmF0Y2gtMjAyNS0x..."
  },
  ...
]
```

**Note**: The `Body` field contains the base64-encoded message (JSON/XML/CSV/PSV), shortened here. The `ExtendedProperties/1.0#RepositoryBinding` in the [Context Options][] contains the integration metadata for visualization.

## :fa-list-ol: Execution Steps

### Step 1: Open PowerShell 7

Open **PowerShell 7** (`pwsh`), for example in Windows Terminal. You don't need administrator rights. Windows PowerShell 5.1 and PowerShell ISE can't run the script; see [Troubleshooting](#fa-screwdriver-wrench-troubleshooting).

```powershell
pwsh
```

### Step 2: Navigate to Demo Directory

Go to the folder where you saved the script:

```powershell
cd "c:\Code\Docs\products-documentation\Integration Manager\Documentation\Repository Model\BPMs\Examples\Order-to-Cash"
```

### Step 3: Set Execution Policy (if needed)

```powershell
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
```

### Step 4: Run the Script

```powershell
# Option A: Preview (dry run - first order only)
.\Generate-O2C-Demo-Data.ps1 -DryRun

# Option B: Export 100 orders to file
.\Generate-O2C-Demo-Data.ps1 -ExportToFile -OutputFile "C:\Temp\O2C-Demo.json"

# Option C: Export custom count to file
.\Generate-O2C-Demo-Data.ps1 -OrderCount 500 -ExportToFile -OutputFile "C:\Temp\O2C-500.json"
```

### Step 5: View Results

```powershell
# Inspect the generated file
Get-Content "C:\Temp\O2C-Demo.json"|ConvertFrom-Json|Measure-Object
Get-Item "C:\Temp\O2C-Demo.json"|Select-Object Length
```

## :fa-plug: Integration with Nodinite

### Post the Exported Events to the Log API

The script never calls the [Log API][LogAPI]. Export the events with `-ExportToFile`, then post them one by one, for example in PowerShell 7 with Windows authentication:

```powershell
Get-Content C:\Temp\O2C-10.json -Raw | ConvertFrom-Json | ForEach-Object {
  Invoke-RestMethod -Method Post -Uri https://{host}:{port}/LogAPI/api/LogEvent `
    -UseDefaultCredentials -ContentType 'application/json' `
    -Body ($_ | ConvertTo-Json -Depth 20) | Out-Null
}
```

*Post each exported Log Event to the Log API with the current Windows identity. Add `-SkipCertificateCheck` only for a self-signed certificate in a test environment.*

The [Logging Service][] files the events within seconds; search them in a [Log View][Log Views] with **Today**. See [Log using REST][] for the v7 Log API endpoint and authentication options.

You can also import the exported JSON into Postman and post the events from a collection.

## :fa-gauge-high: Performance Considerations

### Generation Performance

Generating 100 orders took 2.7 seconds on a test server; the time grows with `-OrderCount`. Posting the events takes longer than generating them: about 2 seconds per 14 events (one order) with the loop above.

### Memory Usage

* Approximately 20-50 MB RAM for 100 orders
* Approximately 100-200 MB RAM for 1000 orders
* JSON serialization uses an efficient approach

### Network Considerations

If you send to the Log API:

* Each event: ~1-2 KB (plus ~3-5 KB Repository Binding in the Context)
* Total for 100 orders: ~1,070 events × ~4 KB average = ~4 MB
* The loop above posts one event per call

## :fa-screwdriver-wrench: Troubleshooting

### Issue: "Unexpected token '?'"

**Solution**: You ran the script in Windows PowerShell 5.1 or PowerShell ISE. It needs PowerShell 7: run it from `pwsh`.

### Issue: The events don't show in the Log View

**Solution**: The events are dated from 06:00 UTC on the day you ran the script. Before 06:00 UTC they're dated later than now, so a search that ends now misses them; search with **Today**. Also check that you posted the exported file: the script itself never calls the Log API.

### Issue: "Cannot find path"

**Solution**: Make sure the PowerShell working directory is the folder with the script:

```powershell
Get-Location
cd "c:\Code\Docs\products-documentation\Integration Manager\Documentation\Repository Model\BPMs\Examples\Order-to-Cash"
```

### Issue: Execution Policy Error

**Solution**: Set the execution policy for the current process:

```powershell
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
```

### Issue: JSON Parse Error

**Solution**: Validate that the generated file is valid JSON:

```powershell
$json = Get-Content "C:\Temp\O2C-Demo.json"|ConvertFrom-Json
$json|Measure-Object  # Should show count of events
```

## :fa-hand-point-right: Next Steps

* :fa-code: [Generate O2C Demo Data Script][Generate-O2C-Demo-Data-Script] — Copy the PowerShell 7+ script, then run it with `-DryRun` to preview the first order  
* :fa-tower-broadcast: [Log API][LogAPI] — Complete testing with the live API  
* :fa-diagram-project: [BPM Expected Layout][] — See the BPM the generated data creates  

## :fa-link-horizontal: Related Topics

* :fa-database: [O2C Demo: Data Generation][O2C Data Generation] — The sample data and how the script generates it  
* :fa-house: [Order-to-Cash Process Demo][Overview] — Complete Order-to-Cash scenario  
* :fa-palette: [Order Received Stylesheet][Order-Stylesheet] — Visualize Step 0 messages  
* :fa-file-lines: [Context Options][] — Understand Context fields  
* :fa-sitemap: [Repository Binding][]  
* :fa-book: [JSON formatted Log Event][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Repository/BPMs/O2C/O2C_GenerateDryRun.gif
[2]:{ndm}/Documentation%20Pictures/IM/WebClient/Repository/BPMs/O2C/O2C_GenerateSmallBatch.gif

[Azure Logic Apps]:{ndr}/Logging%20and%20Monitoring/Azure%20Logic%20Apps/Overview.md
[BPM]:{ndr}/Repository%20Model/BPMs/Overview.md
[BPM Expected Layout]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/BPM-Expected-Layout.md
[Context Options]:{ndr}/Core%20Services/Log%20Event/Features/Context%20Options.md
[Endpoint Types]:{ndr}/Core%20Services/Log%20Event/Features/Endpoint%20Types.md
[Generate-O2C-Demo-Data-Script]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Generate-O2C-Demo-Data-Script.md
[Grouping - Several Fields]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Log%20View%20Grouping%20Tab.md#fa-sitemap-group-on-several-fields
[JSON formatted Log Event]:{ndr}/Core%20Services/Log%20Event/Features/JSON%20Log%20Event.md
[JSON Path]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/JSON%20Path.md
[Log Agents]:{ndr}/Administration/1.%20Log%20Management/3.%20Log%20Agents/Features/What%20is%20a%20Log%20Agent.md
[Log Event]:{ndr}/Core%20Services/Log%20Event/Overview.md
[Log Status Codes]:{ndr}/Administration/1.%20Log%20Management/3.%20Log%20Agents/Features/What%20is%20a%20Log%20Status%20Code.md
[Log using REST]:{ndr}/Core%20Services/Log%20API/Features/Log%20using%20REST.md
[Log View Grouping Tab]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Log%20View%20Grouping%20Tab.md
[Log Views]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/What%20is%20a%20Log%20View.md
[LogAPI]:{ndr}/Core%20Services/Log%20API/Overview.md
[Logging Service]:{ndr}/Core%20Services/Logging%20Service/Overview.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[O2C Data Generation]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/O2C-Data-Generation.md
[O2C Process]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/O2C-Process-and-Services.md
[Order-Stylesheet]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Stylesheets/1-Order-Received.md
[Overview]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Overview.md
[Repository Binding]:{ndr}/Core%20Services/Log%20Event/Features/Repository%20Binding.md
[Repository Model]:{ndr}/Repository%20Model/Overview.md
[Search Fields]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/What%20is%20a%20Search%20Field.md
[Services]:{ndr}/Repository%20Model/Services/Overview.md
[Systems]:{ndr}/Repository%20Model/Systems/Overview.md