DTDS_FileContent¶
Auto-generated by DscResource.DocGenerator
This page is generated from the comment-based help in
dsc/resources/DTDS_FileContent/DTDS_FileContent.psm1 during the CI/CD
pipeline. Run pwsh -File example/dsc/build.ps1 to regenerate locally.
Synopsis¶
Manages the text content of a file in a deterministic way.
Description¶
The DTDS_FileContent resource ensures that a UTF-8 text file at the given
Path either:
- Exists with exactly the specified
Content(Ensure = Present), or - Does not exist (
Ensure = Absent).
It is a class-based DSC resource designed to demonstrate the deterministic
documentation pattern described in the technical design specification.
Documentation is auto-generated from comment-based help blocks by
DscResource.DocGenerator during the CI/CD pipeline.
Requirements¶
- PowerShell 7.2 or later (cross-platform — Windows, Linux, macOS)
- DSC module:
DTDS_FileContentversion 1.0.0
Properties¶
Key Properties¶
| Property | Type | Description |
|---|---|---|
Path |
System.String |
The full path to the file to manage. Acts as the unique DSC key — two DTDS_FileContent declarations in the same configuration must target different paths. |
Mandatory Properties¶
| Property | Type | Description |
|---|---|---|
Content |
System.String |
The exact text content the file must contain. Written verbatim with no trailing newline. Ignored when Ensure = Absent. |
Optional Properties¶
| Property | Type | Default | Description |
|---|---|---|---|
Ensure |
Ensure |
Present |
Whether the file should be Present or Absent. |
Examples¶
Example 1 — Ensure a README exists¶
Configuration EnsureReadme {
Import-DscResource -ModuleName DTDS_FileContent
Node 'localhost' {
DTDS_FileContent PlatformReadme {
Path = 'C:\PlatformWorkspace\README.md'
Content = '# Platform Workspace — managed by DSC'
Ensure = 'Present'
}
}
}
Example 2 — Remove a legacy file¶
Configuration RemoveLegacy {
Import-DscResource -ModuleName DTDS_FileContent
Node 'localhost' {
DTDS_FileContent LegacyLock {
Path = 'C:\PlatformWorkspace\.legacy-lock'
Content = '' # ignored when Ensure = Absent
Ensure = 'Absent'
}
}
}
Example 3 — Cross-platform (Linux path)¶
DTDS_FileContent AppConfig {
Path = '/etc/myapp/config.env'
Content = 'ENV=production'
Ensure = 'Present'
}
Traceability¶
| Field | Value |
|---|---|
| Related ADR | ADR-0004 — DSC for Windows configuration |
| Related Requirements | S-008, S-009 |
| Source file | dsc/resources/DTDS_FileContent/DTDS_FileContent.psm1 |
| Tests | dsc/tests/DTDS_FileContent.Tests.ps1 |