base64
Synopsis
Returnerar base64-representationen av en indatasträng.
Syntax
base64(<inputString>)
Description
Funktionen base64()
returnerar base64-representationen av en indatasträng. Om du skickar data som kodas som base64 kan du minska felen vid dataöverföring, särskilt när olika verktyg kräver olika escape-tecken.
Exempel
Exempel 1 – Konvertera en sträng till base64
Konfigurationen konverterar ett grundläggande strängvärde med base64()
funktionen .
# 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
Exempel 2 – Konvertera en sammanlänkad sträng till base64
Konfigurationen använder funktionen concat() i base64()
funktionen för att kombinera strängarna a
, b
och c
till abc
innan base64-representationen returneras.
# 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
Parametrar
inputString
Funktionen base64()
förväntar sig en enda sträng som indata. Funktionen konverterar värdet till en base64-representation. Om värdet inte är en sträng genererar DSC ett fel när konfigurationsdokumentet verifieras.
Type: string
Required: true
MinimumCount: 1
MaximumCount: 1
Utdata
Funktionen base64()
returnerar base64-representationen av inputString-värdet .
Type: string