-
Notifications
You must be signed in to change notification settings - Fork 51
Add reference docs for logical functions #981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michaeltlombardi
merged 5 commits into
PowerShell:main
from
Gijsreyn:logical-functions-ref-docs
Jul 29, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e0d6390
Add reference docs for logical functions
Gijsreyn 07c24d8
Add reference docs for logical functions
Gijsreyn e62edd4
Merge branch 'logical-functions-ref-docs' of https://github.com/Gijsr…
Gijsreyn d7280eb
Small note added
Gijsreyn 11f78c9
Wrong files commit
Gijsreyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
--- | ||
description: Reference for the 'and' DSC configuration document function | ||
ms.date: 01/19/2025 | ||
ms.topic: reference | ||
title: and | ||
--- | ||
|
||
# and | ||
|
||
## Synopsis | ||
|
||
Returns true if all arguments are true. | ||
|
||
## Syntax | ||
|
||
```Syntax | ||
and(<arg1>, <arg2>, ...) | ||
``` | ||
|
||
## Description | ||
|
||
The `and()` function evaluates if all arguments are true. It takes two or more boolean arguments | ||
and returns `true` only if every argument is `true`. If any argument is `false`, the function | ||
returns `false`. | ||
|
||
This function uses short-circuit evaluation, meaning it returns `false` as soon as it encounters | ||
the first `false` argument without evaluating the remaining arguments. | ||
|
||
## Examples | ||
|
||
### Example 1 - Basic and operation | ||
|
||
This configuration demonstrates basic usage of the `and()` function. | ||
|
||
```yaml | ||
# and.example.1.dsc.config.yaml | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Echo and result | ||
type: Microsoft.DSC.Debug/Echo | ||
properties: | ||
output: "[and(true, true)]" | ||
``` | ||
|
||
```bash | ||
dsc config get --file and.example.1.dsc.config.yaml | ||
``` | ||
|
||
```yaml | ||
results: | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT0.1291763S | ||
name: Echo and result | ||
type: Microsoft.DSC.Debug/Echo | ||
result: | ||
actualState: | ||
output: true | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
### Example 2 - And operation with false value | ||
|
||
This example shows the `and()` function returning false when one argument is false. | ||
|
||
```yaml | ||
# and.example.2.dsc.config.yaml | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Echo and result with false | ||
type: Microsoft.DSC.Debug/Echo | ||
properties: | ||
output: "[and(true, false, true)]" | ||
``` | ||
|
||
```bash | ||
dsc config get --file and.example.2.dsc.config.yaml | ||
``` | ||
|
||
```yaml | ||
results: | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT0.0329292S | ||
name: Echo and result with false | ||
type: Microsoft.DSC.Debug/Echo | ||
result: | ||
actualState: | ||
output: false | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
### Example 3 - And operation with multiple conditions | ||
|
||
This configuration uses the `and()` function with multiple boolean expressions. | ||
|
||
```yaml | ||
# and.example.3.dsc.config.yaml | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Echo complex and operation | ||
type: Microsoft.DSC.Debug/Echo | ||
properties: | ||
output: "[and(equals(5, 5), equals('hello', 'hello'), true)]" | ||
``` | ||
|
||
```bash | ||
dsc config get --file and.example.3.dsc.config.yaml | ||
``` | ||
|
||
```yaml | ||
results: | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT0.0514415S | ||
name: Echo complex and operation | ||
type: Microsoft.DSC.Debug/Echo | ||
result: | ||
actualState: | ||
output: true | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
## Parameters | ||
|
||
### arguments | ||
|
||
The `and()` function requires two or more boolean arguments. | ||
|
||
```yaml | ||
Type: boolean | ||
Required: true | ||
MinimumCount: 2 | ||
MaximumCount: 18446744073709551615 | ||
``` | ||
|
||
## Output | ||
|
||
The `and()` function returns `true` if all arguments are `true`, otherwise it returns `false`. | ||
|
||
```yaml | ||
Type: boolean | ||
``` | ||
|
||
<!-- Link reference definitions --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
--- | ||
description: Reference for the 'bool' DSC configuration document function | ||
ms.date: 01/19/2025 | ||
ms.topic: reference | ||
title: bool | ||
--- | ||
|
||
# bool | ||
|
||
## Synopsis | ||
|
||
Converts a string or number to a boolean value. | ||
|
||
## Syntax | ||
|
||
```Syntax | ||
bool(<value>) | ||
``` | ||
|
||
## Description | ||
|
||
The `bool()` function converts a string or number to a boolean value. For string arguments, | ||
it accepts "true" (case-insensitive) which converts to `true`, and "false" (case-insensitive) | ||
which converts to `false`. For numeric arguments, zero converts to `false` and any non-zero | ||
value converts to `true`. | ||
|
||
> [!NOTE] | ||
> Any string argument other than `true` or `false` (case-insensitive) will raise a DSC error. | ||
|
||
## Examples | ||
|
||
### Example 1 - Convert string to boolean | ||
|
||
This configuration demonstrates converting string values to boolean. | ||
|
||
```yaml | ||
# bool.example.1.dsc.config.yaml | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Echo bool from string | ||
type: Microsoft.DSC.Debug/Echo | ||
properties: | ||
output: | ||
trueValue: "[bool('true')]" | ||
falseValue: "[bool('FALSE')]" | ||
``` | ||
|
||
```bash | ||
dsc config get --file bool.example.1.dsc.config.yaml | ||
``` | ||
|
||
```yaml | ||
results: | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT0.0334711S | ||
name: Echo bool from string | ||
type: Microsoft.DSC.Debug/Echo | ||
result: | ||
actualState: | ||
output: | ||
trueValue: true | ||
falseValue: false | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
### Example 2 - Convert number to boolean | ||
|
||
This example shows the `bool()` function converting numeric values to boolean. | ||
|
||
```yaml | ||
# bool.example.2.dsc.config.yaml | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Echo bool from numbers | ||
type: Microsoft.DSC.Debug/Echo | ||
properties: | ||
output: | ||
zeroIsFalse: "[bool(0)]" | ||
oneIsTrue: "[bool(1)]" | ||
negativeIsTrue: "[bool(-5)]" | ||
positiveIsTrue: "[bool(42)]" | ||
``` | ||
|
||
```bash | ||
dsc config get --file bool.example.2.dsc.config.yaml | ||
``` | ||
|
||
```yaml | ||
results: | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT0.0323199S | ||
name: Echo bool from numbers | ||
type: Microsoft.DSC.Debug/Echo | ||
result: | ||
actualState: | ||
output: | ||
zeroIsFalse: false | ||
oneIsTrue: true | ||
negativeIsTrue: true | ||
positiveIsTrue: true | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
## Parameters | ||
|
||
### value | ||
|
||
The `bool()` function requires a single argument that is either a string or number. | ||
|
||
For strings, valid values are: | ||
- "true" (case-insensitive) - converts to `true` | ||
- "false" (case-insensitive) - converts to `false` | ||
|
||
For numbers: | ||
- 0 - converts to `false` | ||
- Any non-zero value - converts to `true` | ||
|
||
```yaml | ||
Type: [string, integer] | ||
Required: true | ||
MinimumCount: 1 | ||
MaximumCount: 1 | ||
``` | ||
|
||
## Output | ||
|
||
The `bool()` function returns a boolean value based on the input argument. | ||
|
||
```yaml | ||
Type: boolean | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
description: Reference for the 'false' DSC configuration document function | ||
ms.date: 01/19/2025 | ||
ms.topic: reference | ||
title: false | ||
--- | ||
|
||
# false | ||
|
||
## Synopsis | ||
|
||
Returns the boolean value false. | ||
|
||
## Syntax | ||
|
||
```Syntax | ||
false() | ||
``` | ||
|
||
## Description | ||
|
||
The `false()` function returns the boolean value `false`. This function takes no arguments and | ||
always returns `false`. It's useful for providing explicit boolean values in configurations | ||
or for logical operations. | ||
|
||
## Examples | ||
|
||
### Example 1 - Basic false value | ||
|
||
This configuration demonstrates basic usage of the `false()` function. | ||
|
||
```yaml | ||
# false.example.1.dsc.config.yaml | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Echo false value | ||
type: Microsoft.DSC.Debug/Echo | ||
properties: | ||
output: "[false()]" | ||
``` | ||
|
||
```bash | ||
dsc config get --file false.example.1.dsc.config.yaml | ||
``` | ||
|
||
```yaml | ||
results: | ||
- name: Echo false value | ||
type: Microsoft.DSC.Debug/Echo | ||
result: | ||
actualState: | ||
output: false | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
## Parameters | ||
|
||
The `false()` function takes no arguments. | ||
|
||
```yaml | ||
Type: none | ||
Required: false | ||
MinimumCount: 0 | ||
MaximumCount: 0 | ||
``` | ||
|
||
## Output | ||
|
||
The `false()` function always returns the boolean value `false`. | ||
|
||
```yaml | ||
Type: boolean | ||
``` | ||
|
||
<!-- Link reference definitions --> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.