description | ms.date | ms.topic | title |
---|---|---|---|
Reference for the 'add' DSC configuration document function |
03/19/2024 |
reference |
add |
Adds two integers, returning their sum.
add(<operands>)
The add()
function returns the sum of two integers. It adds the second operand to the first
operand. You can nest calls to add()
to sum more than two integers.
This example document shows how you can use the add()
function to return the sum of two integers.
# add.example.1.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Sum of 3 and 5
type: Test/Echo
properties:
output: "[add(3, 5)]"
dsc config get --document add.example.1.dsc.config.yaml
results:
- name: Sum of 3 and 5
type: Test/Echo
result:
actualState:
output: 8
messages: []
hadErrors: false
This example document shows how you can use the add()
function to return the sum of nested
configuration functions that return integer values.
# add.example.2.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Add nested function outputs
type: Test/Echo
properties:
output: "[add(mul(2,3), div(6,3))]"
dsc config get --document add.example.2.dsc.config.yaml
results:
- name: Add nested function outputs
type: Test/Echo
result:
actualState:
output: 8
messages: []
hadErrors: false
The add()
function expects exactly two integers as input. The operands can be either an
integer or the output of any configuration function that returns an integer. Separate the
operands with a comma (,
).
Type: integer
Required: true
MinimumCount: 2
MaximumCount: 2
The add()
function returns an integer representing the sum of the operands.
Type: integer