description | ms.date | ms.topic | title |
---|---|---|---|
Reference for the 'base64' DSC configuration document function |
01/17/2024 |
reference |
base64 |
Returns the base64 representation of an input string.
base64(<inputString>)
The base64()
function returns the base64 representation of an input string. Passing data
encoded as base64 can reduce errors in passing data, especially when different tools require
different escape characters.
The configuration converts a basic string value with the base64()
function.
# base64.example.1.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Echo 'abc' in base64
type: Test/Echo
properties:
output: "[base64('abc')]"
dsc --input-file base64.example.1.dsc.config.yaml config get
results:
- name: Echo 'abc' in base64
type: Test/Echo
result:
actualState:
output: YWJj
messages: []
hadErrors: false
The configuration uses the concat() function inside the base64()
function to combine the
strings a
, b
, and c
into abc
before returning the base64 representation.
# base64.example.2.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Echo concatenated 'a', 'b', 'c' in base64
type: Test/Echo
properties:
output: "[base64(concat('a', 'b', 'c'))]"
dsc --input-file base64.example.2.dsc.config.yaml config get
results:
- name: Echo concatenated 'a', 'b', 'c' in base64
type: Test/Echo
result:
actualState:
output: YWJj
messages: []
hadErrors: false
The base64()
function expects a single string as input. The function converts the value into a
base64 representation. If the value isn't a string, DSC raises an error when validating the
configuration document.
Type: string
Required: true
MinimumCount: 1
MaximumCount: 1
The base64()
function returns the base64 representation of the inputString value.
Type: string