Module to implement string mappings and inserting values into strings.
To install the module from the PSGallery, run:
Install-Module ResolveString
# Register a new mapping
Register-StringMapping -Name '%Date%' -Value (Get-Date -Format 'yyyy-MM-dd') -ModuleName MyModule
# Resolve a string based on the available mappings
Resolve-String -Text 'Today is the date %Date%, it is going to be awesome' -ModuleName MyModule
Note: The ModuleName parameter is optional and will automatically insert the caller's module name. It is only specified in order to be able to run the demo code interactively.
# Register a new mapping, the value of which will be calculated at resolution time
Register-StringMapping -Name '%Date%' -Scriptblock { Get-Date -Format 'yyyy-MM-dd' } -ModuleName MyModule
# Resolve a string based on the available mappings, inserting the dynamically calculated date
Resolve-String -Text 'Today is the date %Date%, it is going to be awesome' -ModuleName MyModule