en-US/about_ReplaceText.help.txt
.NAME
ReplaceText # Description The resource is used to replace strings matching a regular expression in a text file. It can be used to replace strings matched with a regular expression with either a text string or a secret which is provided in the password of a credential object. .PARAMETER Path Key - String The path to the text file to replace the string in. .PARAMETER Search Key - String The RegEx string to use to search the text file. .PARAMETER Type Write - String Allowed values: Text, Secret Specifies the value type to use as the replacement string. Defaults to 'Text'. .PARAMETER Text Write - String The text to replace the text identified by the RegEx. Only used when Type is set to 'Text'. .PARAMETER Secret Write - String The secret text to replace the text identified by the RegEx. Only used when Type is set to 'Secret'. .PARAMETER AllowAppend Write - Boolean Specifies to append text to the file being modified. Adds the ability to add a configuration entry. PSScriptInfo .VERSION 1.0.0 .GUID 6a6a7523-91c3-4038-b7f1-178b8dd6803d .AUTHOR Daniel Scott-Raynsford .COMPANYNAME .COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. .TAGS DSCConfiguration .LICENSEURI https://github.com/PlagueHO/FileContentDsc/blob/master/LICENSE .PROJECTURI https://github.com/PlagueHO/FileContentDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES First version. .PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core #Requires -module FileContentDsc .DESCRIPTION Set all occrurances of the string `%secret%` to be the value in the password set in the parameter $Secret PSCredential object in the file `c:\inetpub\wwwroot\default.htm`. Configuration ReplaceText_ReplacePlainSecretText_Config { param ( [Parameter()] [ValidateNotNullorEmpty()] [PSCredential] $Secret ) Import-DSCResource -ModuleName FileContentDsc Node localhost { ReplaceText SetSecretText { Path = 'c:\inetpub\wwwroot\default.htm' Search = '%secret%' Type = 'Secret' Secret = $Secret } } } PSScriptInfo .VERSION 1.0.0 .GUID 40050783-8d84-4d71-be0c-a03c8da76133 .AUTHOR Daniel Scott-Raynsford .COMPANYNAME .COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. .TAGS DSCConfiguration .LICENSEURI https://github.com/PlagueHO/FileContentDsc/blob/master/LICENSE .PROJECTURI https://github.com/PlagueHO/FileContentDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES First version. .PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core #Requires -module FileContentDsc .DESCRIPTION Set all occrurances of the string `%appname%` to be Awesome App` in the file `c:\inetpub\wwwroot\default.htm`. Configuration ReplaceText_ReplacePlainText_Config { Import-DSCResource -ModuleName FileContentDsc Node localhost { ReplaceText SetText { Path = 'c:\inetpub\wwwroot\default.htm' Search = '%appname%' Type = 'Text' Text = 'Awesome App' } } } PSScriptInfo .VERSION 1.0.0 .GUID b29bfcd1-95e1-47e1-971c-a2fffb223113 .AUTHOR Daniel Scott-Raynsford .COMPANYNAME .COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. .TAGS DSCConfiguration .LICENSEURI https://github.com/PlagueHO/FileContentDsc/blob/master/LICENSE .PROJECTURI https://github.com/PlagueHO/FileContentDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES First version. .PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core #Requires -module FileContentDsc .DESCRIPTION Set all occrurances of a string matching the regular expression `<img src=['``"][a-zA-Z0-9.]*['``"]>` with the text `<img src="imgs/placeholder.jpg">` in the file `c:\inetpub\wwwroot\default.htm` Configuration ReplaceText_ReplaceRegexText_Config { Import-DSCResource -ModuleName FileContentDsc Node localhost { ReplaceText SetTextWithRegex { Path = 'c:\inetpub\wwwroot\default.htm' Search = "<img src=['`"][a-zA-Z0-9.]*['`"]>" Type = 'Text' Text = '<img src="imgs/placeholder.jpg">' } } } |