Update module version to 1.0.1 and add new functions for exporting and deploying DSC configuration data

This commit is contained in:
Torsten Brendgen
2026-07-03 11:59:18 +02:00
parent fcbe61902f
commit fb9209456b
9 changed files with 491 additions and 8 deletions

View File

@@ -0,0 +1,32 @@
function Export-PowerShellDataFile {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[System.Collections.IDictionary]
$InputObject,
[Parameter(Mandatory=$true)]
[string]
$Path,
[Parameter(Mandatory=$false)]
[switch]
$Force
)
process {
$ResolvedPath = Repair-ConfigurationDataPathEncoding -Path $Path
if((Test-Path -LiteralPath $ResolvedPath -PathType Leaf) -and (-not $Force)){
throw "File [$ResolvedPath] already exists. Use -Force to overwrite it."
}
$Parent = Split-Path -Path $ResolvedPath -Parent
if(-not [string]::IsNullOrWhiteSpace($Parent) -and -not (Test-Path -LiteralPath $Parent)){
New-Item -Path $Parent -ItemType Directory -Force | Out-Null
}
$Text = ConvertTo-PowerShellDataFileText -InputObject $InputObject
Set-Content -LiteralPath $ResolvedPath -Value $Text -Encoding UTF8
}
}