DK Plus cmdlets write objects, not text. What you see in the console is a view of those objects, and everything the client read is still on them.
The module ships a format file with table views for the common read models: customers, products, projects, orders, invoices, employees, and more. The default columns are the same ones devop-dk shows for the matching list command, with the same headings. For example, Get-Customer and devop-dk customer list show the same columns, and sensitive properties are never part of a default view.
Get-Customer -Take 5
Get-SalesPerson
Cmdlets for types without a view fall back to PowerShell's normal formatting.
The CLI personalizes tables with config columns. The module has no such setting. Use the PowerShell tools instead:
# A different set of columns
Get-Customer -Take 20 | Format-Table Number, Name, Email, Balance
# Wider than the default view
Get-Product -Group 01 -Take 10 | Format-Table -AutoSize *
# One record, every property
Get-Customer -Number 10001 | Format-List *
# Keep only some properties for later steps
Get-Customer -Take 100 | Select-Object Number, Name, Email | Export-Csv customers.csv -NoTypeInformation
Select-Object changes the objects, so use Format-Table and Format-List only as the last step of a pipeline.
Every object carries all of its nested sections. The CLI's --expand has no counterpart, because you can read them directly:
(Get-Customer -Number 10001).Contacts | Format-Table Number, Name, Email
(Get-Company).Information.Company.Name
The CLI's --json is ConvertTo-Json. Pass -Depth for nested sections, because the default depth is shallow:
Get-Customer -Number 10001 | ConvertTo-Json -Depth 6
Get-Order -Status OnHold -Take 25 | ConvertTo-Json -Depth 6 -EnumsAsStrings
-EnumsAsStrings writes enum members by name, as the CLI's JSON does. Without it, PowerShell writes numbers. JSON output does not depend on your culture. Get-Employee never returns payroll data, Get-Webhook never returns the authorization value, and Get-Token masks token values unless you pass -ShowToken (see Safety and errors).
To start a JSON document for a create command, convert a hashtable or a template and pass the file with -Path:
Get-WebhookTemplate | ConvertTo-Json -Depth 5 | Set-Content webhook.json
Some commands write a file instead of an object. In the module these are the Save-* cmdlets:
| Cmdlet | Saves | Default file name |
|---|---|---|
Save-InvoicePdf |
Sales invoice PDF | <number>.pdf |
Save-OrderPdf |
Sales order PDF | sales-order-<number>.pdf |
Save-QuotePdf |
Sales quote PDF | sales-quote-<number>.pdf |
Save-VendorInvoiceAttachment |
Vendor invoice attachment | the attachment's own name |
Save-TokenReport |
Token usage report PDF | none: -Path is required |
The HTML cmdlets Get-InvoiceHtml, Get-OrderHtml, and Get-QuoteHtml return HTML text. Add -Path (and -Force to replace a file) to save it to a file instead; they then follow the rules below.
All of them follow the same rules:
-Path (alias -Output) names the file. Without it, the default file name is used in the current location. A relative path is resolved against your current PowerShell location. Missing folders are created.-Force replaces an existing file. Without it, an existing file is refused with an error that names -Force, and no request is sent. A path that is an existing folder is refused too.FileInfo for the saved file, so you can chain on it.-Path names a single file. When a second record arrives from the pipeline with -Path set, the command ends with the terminating DkPlus.OutputPathReused error before that record's request. Use the default names, or call the cmdlet in a loop with a path per record.Save-VendorInvoiceAttachment write a non-terminating DkPlus.NotFound error and no file when DK Plus returns nothing. The PDF cmdlets report a rejected request (for example a 404) as an ordinary request error such as DkPlus.Request.404, and write no file.# Default name in the current folder
Save-InvoicePdf 12345
# A chosen path, replacing an existing file
Save-InvoicePdf 12345 -Path ./pdf/invoice-12345.pdf -Force
# Output is a FileInfo
Save-InvoicePdf 12345 -Output ./pdf/invoice-12345.pdf | Select-Object FullName, Length
# One file per order
Get-Order -Status OnHold | ForEach-Object { Save-OrderPdf $_.Number -Path "./pdf/order-$($_.Number).pdf" }
# A report with a required path
Save-TokenReport ./token-usage.pdf -From (Get-Date).AddMonths(-1)
# HTML text or file
Get-QuoteHtml 12345 | Set-Content ./quote.html
Get-QuoteHtml 12345 -Path ./quote-12345.html
Cmdlets write only data to the output stream. Library logs go to the Verbose stream; add -Verbose to see them. Errors go to the error stream, so Export-Csv and ConvertTo-Json never contain error text.