|
| 1 | +--- |
| 2 | +description: Reference for the 'greaterOrEquals' DSC configuration document function |
| 3 | +ms.date: 07/24/2025 |
| 4 | +ms.topic: reference |
| 5 | +title: greaterOrEquals |
| 6 | +--- |
| 7 | + |
| 8 | +# greaterOrEquals |
| 9 | + |
| 10 | +## Synopsis |
| 11 | + |
| 12 | +Checks whether the first value is greater than or equal to the second value. |
| 13 | + |
| 14 | +## Syntax |
| 15 | + |
| 16 | +```Syntax |
| 17 | +greaterOrEquals(<firstValue>, <secondValue>) |
| 18 | +``` |
| 19 | + |
| 20 | +## Description |
| 21 | + |
| 22 | +The `greaterOrEquals()` function checks whether the first value is greater |
| 23 | +than or equal to the second value, returning `true` if it is and otherwise `false`. |
| 24 | +You can use this function to compare two values of the same data type. If the values |
| 25 | +are different types, like a string and an integer, DSC returns an error for this function. |
| 26 | + |
| 27 | +For strings, the comparison is case-sensitive and uses lexicographic ordering based on character codes. |
| 28 | + |
| 29 | +## Examples |
| 30 | + |
| 31 | +### Example 1 - Compare two numbers |
| 32 | + |
| 33 | +The following example shows how you can use the function to compare two numbers. |
| 34 | + |
| 35 | +```yaml |
| 36 | +# greaterOrEquals.example.1.dsc.config.yaml |
| 37 | +$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 38 | +resources: |
| 39 | +- name: Compare numbers |
| 40 | + type: Microsoft.DSC.Debug/Echo |
| 41 | + properties: |
| 42 | + output: |
| 43 | + firstGreater: "[greaterOrEquals(5, 3)]" |
| 44 | + secondGreater: "[greaterOrEquals(3, 5)]" |
| 45 | + equalNumbers: "[greaterOrEquals(5, 5)]" |
| 46 | +``` |
| 47 | +
|
| 48 | +```bash |
| 49 | +dsc config get --file greaterOrEquals.example.1.dsc.config.yaml |
| 50 | +``` |
| 51 | + |
| 52 | +```yaml |
| 53 | +results: |
| 54 | +- name: Compare numbers |
| 55 | + type: Microsoft.DSC.Debug/Echo |
| 56 | + result: |
| 57 | + actualState: |
| 58 | + output: |
| 59 | + firstGreater: true |
| 60 | + secondGreater: false |
| 61 | + equalNumbers: true |
| 62 | +messages: [] |
| 63 | +hadErrors: false |
| 64 | +``` |
| 65 | +
|
| 66 | +### Example 2 - Compare two strings |
| 67 | +
|
| 68 | +The following example shows how you can use the function to compare two strings. |
| 69 | +
|
| 70 | +```yaml |
| 71 | +# greaterOrEquals.example.2.dsc.config.yaml |
| 72 | +$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 73 | +resources: |
| 74 | +- name: Compare strings |
| 75 | + type: Microsoft.DSC.Debug/Echo |
| 76 | + properties: |
| 77 | + output: |
| 78 | + lexicographicGreater: "[greaterOrEquals('b', 'a')]" |
| 79 | + lexicographicLess: "[greaterOrEquals('a', 'b')]" |
| 80 | + equalStrings: "[greaterOrEquals('a', 'a')]" |
| 81 | + caseSensitive: "[greaterOrEquals('Aa', 'aa')]" |
| 82 | +``` |
| 83 | +
|
| 84 | +```bash |
| 85 | +dsc config get --file greaterOrEquals.example.2.dsc.config.yaml |
| 86 | +``` |
| 87 | + |
| 88 | +```yaml |
| 89 | +results: |
| 90 | +- name: Compare strings |
| 91 | + type: Microsoft.DSC.Debug/Echo |
| 92 | + result: |
| 93 | + actualState: |
| 94 | + output: |
| 95 | + lexicographicGreater: true |
| 96 | + lexicographicLess: false |
| 97 | + equalStrings: true |
| 98 | + caseSensitive: false |
| 99 | +messages: [] |
| 100 | +hadErrors: false |
| 101 | +``` |
| 102 | +
|
| 103 | +### Example 3 - Type mismatch error |
| 104 | +
|
| 105 | +The following example shows what happens when you try to compare different types. |
| 106 | +
|
| 107 | +```yaml |
| 108 | +# greaterOrEquals.example.3.dsc.config.yaml |
| 109 | +$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 110 | +resources: |
| 111 | +- name: Type mismatch |
| 112 | + type: Microsoft.DSC.Debug/Echo |
| 113 | + properties: |
| 114 | + output: "[greaterOrEquals('5', 3)]" |
| 115 | +``` |
| 116 | +
|
| 117 | +```bash |
| 118 | +dsc config get --file greaterOrEquals.example.3.dsc.config.yaml |
| 119 | +``` |
| 120 | + |
| 121 | +This will result in an error because you cannot compare a string with a number. |
| 122 | + |
| 123 | +## Parameters |
| 124 | + |
| 125 | +### firstValue |
| 126 | + |
| 127 | +The first value to compare. Must be the same type as the second value. |
| 128 | + |
| 129 | +```yaml |
| 130 | +Type: [number, string] |
| 131 | +Required: true |
| 132 | +``` |
| 133 | +
|
| 134 | +### secondValue |
| 135 | +
|
| 136 | +The second value to compare. Must be the same type as the first value. |
| 137 | +
|
| 138 | +```yaml |
| 139 | +Type: [number, string] |
| 140 | +Required: true |
| 141 | +``` |
| 142 | +
|
| 143 | +The `greaterOrEquals()` function expects exactly two input values of the same type. |
| 144 | +Separate each value with a comma. If the type of the second input value is different |
| 145 | +from the first value, DSC returns an error for the function. |
| 146 | + |
| 147 | +String comparisons are case-sensitive and use lexicographic ordering. |
| 148 | + |
| 149 | +## Output |
| 150 | + |
| 151 | +The `greaterOrEquals()` function returns `true` if the first value is greater than |
| 152 | +or equal to the second value and otherwise `false`. |
| 153 | + |
| 154 | +```yaml |
| 155 | +Type: bool |
| 156 | +``` |
| 157 | + |
| 158 | +<!-- Link reference definitions --> |
0 commit comments