Skip to content

MoldScript

Manjunath Beli edited this page Jul 15, 2024 · 1 revision

Mold Script takes your templates beyond simple text replacement. It lets you weave in custom logic using the power of PowerShell. All the user inputs are at your fingertips within this script, ready to be used in your custom logic.

Important

Mold script must be named as MOLD_SCRIPT.ps1 and kept in root of template folder

Sample MOLD_SCRIPT.ps1 content, using script to rename the file function.ps1 to Get-Something.ps1

param($MoldData)
# File name will be set GetSomething.ps1 when input for functinName is Get-Something
$FuncFileName = $($MoldData.FunctionName -replace '-', '') + '.ps1'
Rename-Item -Path 'Function.ps1' -NewName $FuncFileName

Few things to note about MOLD_SCRIPT.ps1

  • Template Sandboxing: Mold Script can only modify the contents within the template, not the final destination. This keeps things tidy and predictable.
  • Script will be ran as last step after all input is collected.
  • All the parameters and responses are neatly packaged in a hashtable called $MoldData, which you should declare in your script's param block.
Clone this wiki locally