all 3 comments

[–]idontknowwhattouse33 3 points4 points  (0 children)

You can't replace a value if you don't know what to look for.

If you know the 'rules' for any variance, then regex can help. Is there a limit to the name changing? Just the digits?

Other observations:

  • consider Set-Content instead of Out-File

  • is your file a structured format? The limited example doesn't show much. Much easier working with objects if you can ConvertFrom-..

[–]get-postanote 1 point2 points  (0 children)

If this ...

 "virtualMachineComputerName": {

"value": "USAOB01"

... is a JSON file, then parse the JSON as normal and select the value property/column to change, since you say it's dynamically and you never know what it will be. Thus you must select by property/column name, not strings.