In the code below, I am searching through an .ini file and trying to replace certain lines with updated configurations. I've seen it done for single lines, but I am trying to do it for multiple & different lines. When trying to use a backtick
, I get Unexpected token '^' in expression or statement.
.
$layout_choice = "TEST"
$store_pics_by_date_choice = "TEST"
$orientation_choice = "TEST"
$copy_strips_choice = $backup_path
$copy_pics_choice = "no"
$copy_gifs_choice = $backup_path
$copy_videos_choice = "no"
$viewer_monitor_choice = "TEST"
get-content $file | ForEach-Object{$_ -replace "^layout =.+$", "layout = $layout_choice"`
-replace "^store_pics_by_date =.+$", "store_pics_by_date = $store_pics_by_date_choice"
-replace "^orientation =.+$", "orientation = $orientation_choice"
-replace "^copy_strips =.+$", "copy_strips = $copy_strips_choice"
-replace "^copy_gifs =.+$", "copy_gifs = $copy_gifs_choice"
-replace "^copy_pics =.+$", "copy_pics = $copy_pics_choice"
-replace "^copy_videos =.+$", "copy_videos = $copy_videos_choice"
-replace "viewer_monitor =.+", "viewer_monitor = $viewer_monitor_choice"
-replace "viewer_monitor =.+", "viewer_monitor = $viewer_monitor_choice"} | Set-Content ($newfile)