description | ms.date | ms.topic | title |
---|---|---|---|
Reference for the 'min' DSC configuration document function |
04/09/2024 |
reference |
min |
Returns the minimum value from an array of integers or a comma-separated list of integers.
min(<integerList>)
The min
function returns the minimum value from an array of integers or a comma-separated list of
integers.
This configuration returns the smallest number from a list of integers.
# min.example.1.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Echo minimum value
type: Test/Echo
properties:
output: "[min(3, 2, 5, 1, 7)]"
dsc config get --document min.example.1.dsc.config.yaml config get
results:
- name: Echo minimum value
type: Test/Echo
result:
actualState:
output: 1
messages: []
hadErrors: false
This configuration echoes the smallest 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.
# min.example.2.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Echo integer array
type: Test/Echo
properties:
output:
- 3
- 2
- 5
- 1
- 7
- name: Echo minimum integer
type: Test/Echo
properties:
output: >-
[min(
reference(
resourceId('Test/Echo', 'Echo integer array')
).actualState.output
)]
dependsOn:
- "[resourceId('Test/Echo', 'Echo integer array')]"
dsc config get --document min.example.2.dsc.config.yaml
results:
- name: Echo integer array
type: Test/Echo
result:
actualState:
output:
- 3
- 2
- 5
- 1
- 7
- name: Echo minimum integer
type: Test/Echo
result:
actualState:
output: 1
The min()
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. You can use the
createArray() function to combine multiple arrays or an array and additional integers.
Type: [integer, array(integer)]
Required: true
MinimumCount: 1
MaximumCount: 18446744073709551615
The min()
function returns a single integer representing the smallest value in the input.
Type: integer