Param ( [string]$FilePath ) # Define the search string and replacement line $SearchString = ' ' $ReplacementLine = ' ' if (-not (Test-Path -LiteralPath $FilePath -PathType Leaf)) { Write-Error "File '$FilePath' does not exist." exit 1 } try { # Read the file content $content = Get-Content -LiteralPath $FilePath -Encoding UTF8 # Process each line $modifiedContent = $content | ForEach-Object { if ($_.StartsWith($SearchString)) { # Replace the line $ReplacementLine } else { $_ } } # Write the modified content back to the file $modifiedContent | Set-Content -LiteralPath $FilePath -Encoding UTF8 Write-Host "The file '$FilePath' has been updated." exit 0 } catch { Write-Error "An error occurred: $_" exit 1 }