- 12 minutes to read

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 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 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)
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.

Understanding the Data Generator

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

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

Quick Facts

  • Script: Copy the source from 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; 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
  • Log Agent: The script logs as Log Agent 5 ($LOG_AGENT_VALUE_ID), with Endpoint Type 60

Note

5 is also the default Log Agent 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 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.

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 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 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, and on the 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 for a walkthrough.

Use Cases and Execution

Use Case 1: Quick Preview (Dry Run)

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

.\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.

.\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, import them into Postman, or analyze BPM flows.

Use Case 3: Small Batch (Development/Testing)

Scenario: Generate fewer orders for rapid testing cycles.

.\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)
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, and search the Contoso: Orders Log View 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.

.\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.

.\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. Use: Live BPM visualization, real-time integration landscape updates, demonstrations.

Key Features

  • 7-Step 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)

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:

[
  {
    "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.

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.

pwsh

Step 2: Navigate to Demo Directory

Go to the folder where you saved the script:

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

Step 3: Set Execution Policy (if needed)

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

Step 4: Run the Script

# 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

# 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

Integration with Nodinite

Post the Exported Events to the Log API

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

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 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.

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

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:

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:

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

Issue: JSON Parse Error

Solution: Validate that the generated file is valid JSON:

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

Next Steps