I have script, which fetches a text file (which is a script of a database) into a variable. Here is a portion of that script:$DBScriptFile = $Path + $dbname + '\01-DB-' + $dbname + '-' + $Date + '.sql' $string = Get-Content $DBScriptFile
Inside the file I have strings like:SIZE = 76288MB FILEGROWTH = 512MB
I need to replace them with:SIZE = 1024KB FILEGROWTH = 1024KB
The problem is, those numbers may be different, e.g.:SIZE = 10000KB FILEGROWTH = 2048KB
So I need to replace everything which looks like:SIZE = XYZB FILEGROWTH = XYZBwith: SIZE = 1024KB FILEGROWTH = 1024KB
This is not uncommon when you present only a partial representation of the data. We come up with solutions based on what you've shown us. This happens so often I came up with a standard response (this is NOT original to this post).
<StandardRequest rant="false" personal="false">In the future, please post several lines of "real" data, sanitized as necessary. It's been our overwhelming experience that made up sample data (though it makes perfect sense in the mind of the original poster) is rarely ever accurate. This results in multiple iterations trying to get to something that works with the real data. This just wastes time and frustrates everyone. Your cooperation is greatly appreciated.</StandardRequest>
Powered by IDERA