functions/Complete-TokenTransform.ps1
<#
.SYNOPSIS Completes transform on content with provided configObject .DESCRIPTION Completes transform on content with provided configObject .PARAMETER ConfigObject ConfigObject to use .PARAMETER content Content to change .EXAMPLE Complete-TokenTransform -ConfigObject @{"Test"="Tested"} -content "__Test__" .NOTES General notes #> function Complete-TokenTransform { [CmdletBinding()] param( [parameter(Mandatory=$true)] $ConfigObject, [parameter(Mandatory=$true)] $content ) begin {} process { $ConfigObject.Keys | ForEach-Object { $theKey = $_ Write-Information "Searching for token: __$($theKey)__" $token = "__$($thekey)__" if ($content.Contains($token)) { Write-Information "Replacing $token with $($ConfigObject[$theKey])" $content = $content.Replace($token, $ConfigObject[$theKey]) } else { Write-Information "$token not found in $theFile" } } } end { $content } } |