FileContent.FindAndReplace
Method | |
---|---|
Module | FileContent |
Library | FileContent |
Action | Replaces a string in a file with another string. |
Parameters | |
Return values | LineContent (string): The content of the line after a replacement occurred. BackupFileName (string): The full path of the backup file created if |
Example | Replace the first occurrence of 'AuthenticationPolicy=optional' with 'AuthenticationPolicy=required' regardless of case, making a backup of the file before the replacement occurs. @FilePath = "C:\\temp\\Examples\\Example.conf"; @findString = "AuthenticationPolicy=optional"; @replaceString = "AuthenticationPolicy=required"; FileContent.FindAndReplace(FilePath: @FilePath, FindString: @findString, ReplaceString: @replaceString, Backup:true, CaseSensitive:false); |
Platforms |
|
Notes | When a huge file is used with a lot of replacement, the Agent will consume high CPU and will take more time to process the instruction. |