Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

PowerShell – UNIX SED Equivalent – Change Text In File

Posted on March 3, 2016March 3, 2016 By David Kittell

Unix SED command is very useful to make changes to a configuration file when you know what the default values are, below is a way to do a SED-like text change in PowerShell

(Get-Content c:\temp\test.txt).replace('[MYID]', 'MyValue') | Set-Content c:\temp\test.txt

Example: TeamCity Build Agent Configuration file needs updated so it knows where the server is.

$TeamCityConfPath = 'C:\TeamCity\buildAgent\conf\buildAgent.properties'
(Get-Content $TeamCityConfPath).replace('serverUrl=http://localhost:8111/', 'serverUrl=http://someserver:1234/') | Set-Content $TeamCityConfPath
(Get-Content $TeamCityConfPath).replace('name=Default Agent', 'name=TeamCityBA1') | Set-Content $TeamCityConfPath
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code PowerShell sedUNIX Equivalent

Post navigation

Previous post
Next post

Related Posts

PHP – Latitude Latitude to Maidenhead Grid – HAM Radio

Posted on June 14, 2020August 17, 2024

Recently I was asked by a HAM Radio friend to work on a conversion of latitude and longitude coordinates to maidenhead grid. The code below is in “rough” PHP code on purpose to help illustrate the math behind the conversion. Feel free to clean/optimize it all I ask is that…

Read More

Show Records Not In Another Table – Concatenated

Posted on September 24, 2013October 26, 2015

SELECT col1 ,col2 FROM table1 WHERE (col1 + ‘ ‘ + col2) NOT IN ( SELECT (col1 + ‘ ‘ + col2) FROM table2 ) Originally Posted on September 24, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any…

Read More

Shell and Wait

Posted on December 14, 2013October 26, 2015

Public Sub ShellandWait(ByVal ProcessPath As String) Dim objProcess As System.Diagnostics.Process Try objProcess = New System.Diagnostics.Process objProcess.StartInfo.FileName = ProcessPath objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal objProcess.Start() ‘Wait until the process passes back an exit code objProcess.WaitForExit() ‘Free resources associated with this process objProcess.Close() Catch MessageBox.Show("Could not start process " & ProcessPath, "Error") End Try…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • Front Page
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories
  • Raspberry Pi - Remove Default Apps
  • PowerShell - Change Windows CD/DVD Drive Letter
©2025 David Kittell | WordPress Theme by SuperbThemes