| document type | cmdlet |
|---|---|
| external help file | FabricTools-Help.xml |
| HelpUri | |
| Locale | en-US |
| Module Name | FabricTools |
| ms.date | 04/01/2026 |
| PlatyPS schema version | 2024-05-01 |
| title | Convert-ToBase64 |
Encodes the content of a file into a Base64-encoded string.
Convert-ToBase64 [-filePath] <string> [<CommonParameters>]
The Convert-ToBase64 function takes a file path as input, reads the file's content as a byte array, and converts it into a Base64-encoded string. This is useful for embedding binary data (e.g., images, documents) in text-based formats such as JSON or XML.
Output: VGhpcyBpcyBhbiBlbmNvZGVkIGZpbGUu
Convert-ToBase64 -filePath "C:\Path\To\File.txt"This saves the Base64-encoded content of the image to a text file.
$encodedContent = Convert-ToBase64 -filePath "C:\Path\To\Image.jpg
$encodedContent | Set-Content -Path "C:\Path\To\EncodedImage.txt" This saves the Base64-encoded content of the image to a text file.The full path to the file whose contents you want to encode into Base64.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
{{ Fill in the Description }}
- Ensure the file exists at the specified path before running this function.
- Large files may cause memory constraints due to full loading into memory.
Author: Tiago Balabuch
{{ Fill in the related links here }}