Under a root directory, we have multiple subdirectories, each containing, amongst other things, configuration files. Each of these configuration files has a file extension of .config.
Occasionally, in order to manually handle data, a developer will make a change to a file, run the process and then change the file back. But, not always.
Thus, from time-to-time, we are left with a file that runs in an unexpected way in production. The overwhelming number of times a file is changes, one of the properties is overridden. Normally, the line should read:
But it will be changed to:
Often, we will have both lines, but one will be preceded with a '#', rendering it a comment to the engine processing the file.
I would like to create a process in PowerShell that will read every file that has an extension of .config, look for a row that starts with 'insert.only', and make sure it ends with 'true'. If one is found with a value other than 'true' (although the only other value should be 'false') then write out the full filename. I don't necessarily need the line number or the actual value, since the files are small, and the only values for the row should be 'insert.only=true', 'insert.only=false', '#insert.only=true' or '#insert.only=false'.
If a line is found that starts with 'insert.only' without the preceding hashtag, and does not end with 'true' then it is in error.
If insert.only is not found, I would also like to optionally report on that. However, I need an easy way to comment out that piece, because I may not be able to filter my input file selection (e.g. which files to search) and if not, those results would be invalid, since only certain types of configuration files use the insert.only parameter.