Use (V3 version):
(Get-Content c:\temp\test.txt).replace('[MYID]', 'MyValue') | Set-Content c:\temp\test.txt
Or for V2:
(Get-Content c:\temp\test.txt) -replace '\[MYID\]', 'MyValue' | Set-Content c:\temp\test.txt
More Related Contents:
- PowerShell says “execution of scripts is disabled on this system.”
- Create objects with custom properties containing derived filesystem path information and export them to a CSV – calculated properties
- What’s the best way to determine the location of the current PowerShell script?
- Using a Variable (PowerShell) inside of a command
- Changing PowerShell’s default output encoding to UTF-8
- Use Invoke-WebRequest with a username and password for basic authentication on the GitHub API
- redirecting test-path output to text file
- Upload files with FTP using PowerShell
- How can I force Powershell to return an array when a call only returns one object?
- Save hash table in PowerShell object notation (PSON)
- Powershell “private” scope seems not useful at all
- When should I use Write-Error vs. Throw? Terminating vs. non-terminating errors
- How do I write to standard error in PowerShell?
- Saving credentials for reuse by powershell and error ConvertTo-SecureString : Key not valid for use in specified state
- Controlling column widths with Format-Table
- Calling dynamic variable in PowerShell
- Iterate over PSObject properties in PowerShell
- How to use the curl command in PowerShell?
- Ignoring an errorlevel != 0 in Windows PowerShell (ISE)
- $string.Substring Index/Length exception
- DateTime subtraction not working in PowerShell – assignment vs. equality operator
- Loading Assemblies from NuGet Packages
- Issue with Powershell update string in each file within a folder
- How can I run a PowerShell script with white spaces in the path from the command line?
- Output file doesn’t match Write-Host
- Running CMD command in PowerShell
- Using Powershell environmental variables as strings when outputting files
- PowerShell launch script in new instance
- Remove last line from file with Powershell
- How to return specific data type from PowerShell function i.e. DataTable