description | ms.date | ms.topic | title |
---|---|---|---|
Reference for the 'int' DSC configuration document function |
06/13/2024 |
reference |
int |
Returns an integer from an input string or integer.
int(<inputValue>)
The int()
function returns an integer, converting an input string into an integer. If you pass an
integer, it returns the integer. If you pass any other value, including a non-integer number, the
function raises an invalid input error.
This configuration returns an integer, converting the string value '4.7'
to 4
.
# int.example.1.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Echo integer value
type: Test/Echo
properties:
output: "[int('4.7')]"
dsc config get --document int.example.1.dsc.config.yaml config get
results:
- name: Echo integer value of '4.7'
type: Test/Echo
result:
actualState:
output: 4
messages: []
hadErrors: false
The int()
function expects input as either a string or an integer. If the value is a string that
can't be parsed as a number DSC returns an error for the function. If the value isn't a string or
integer, DSC returns an invalid input error for the function.
Type: [String, Integer]
Required: true
MinimumCount: 1
MaximumCount: 1
The int()
function returns an integer representation of the input. If the input value is a string
or number with a fractional part, the function returns the integer without the fractional part. It
doesn't round up, so for an input value of 4.999
the function returns 4
.
Type: integer