| description | Reference for the 'max' DSC configuration document function |
|---|---|
| ms.date | 02/28/2025 |
| ms.topic | reference |
| title | max |
Returns the maximum value from a set of integers.
max(<integerList>)The max() function returns the maximum value from an array of integers or a comma-separated list
of integers.
This configuration returns the largest number from a list of integers.
# max.example.1.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo maximum value
type: Microsoft.DSC.Debug/Echo
properties:
output: "[max(3, 2, 5, 1, 7)]"dsc config get --file max.example.1.dsc.config.yaml config getresults:
- name: Echo maximum value
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: 7
messages: []
hadErrors: falseThis configuration echoes the largest number from an array of integers that is retrieved as a reference to another resource instance. It uses YAML's folded multiline syntax to make the function more readable.
# max.example.2.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo integer array
type: Microsoft.DSC.Debug/Echo
properties:
output:
- 3
- 2
- 5
- 1
- 7
- name: Echo maximum integer
type: Microsoft.DSC.Debug/Echo
properties:
output: >-
[max(
reference(
resourceId('Microsoft.DSC.Debug/Echo', 'Echo integer array')
).actualState.output
)]
dependsOn:
- "[resourceId('Microsoft.DSC.Debug/Echo', 'Echo integer array')]"dsc config get --file max.example.2.dsc.config.yamlresults:
- name: Echo integer array
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output:
- 3
- 2
- 5
- 1
- 7
- name: Echo maximum integer
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: 7The max() function expects either a single array of integers or a comma-separated array of
integers. When you pass integers directly, separate each integer with a comma. When you pass an
array object, the function only takes a single array as an argument.
Type: [integer, array(integer)]
Required: true
MinimumCount: 1
MaximumCount: 18446744073709551615The max() function returns a single integer representing the largest value in the input.
Type: integer