<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Powershell Replace-String Function</title>
	<atom:link href="http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/</link>
	<description></description>
	<lastBuildDate>Sat, 12 Nov 2011 20:10:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: aaron</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-909</link>
		<dc:creator>aaron</dc:creator>
		<pubDate>Thu, 25 Feb 2010 20:23:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-909</guid>
		<description>I think you could use the Excel COM API from within powershell (though I haven&#039;t tried it so I don&#039;t have much specific advice). Maybe this link will be helpful...
http://blogs.technet.com/heyscriptingguy/archive/2006/09/08/how-can-i-use-windows-powershell-to-automate-microsoft-excel.aspx</description>
		<content:encoded><![CDATA[<p>I think you could use the Excel COM API from within powershell (though I haven&#8217;t tried it so I don&#8217;t have much specific advice). Maybe this link will be helpful&#8230;<br />
<a href="http://blogs.technet.com/heyscriptingguy/archive/2006/09/08/how-can-i-use-windows-powershell-to-automate-microsoft-excel.aspx" rel="nofollow">http://blogs.technet.com/heyscriptingguy/archive/2006/09/08/how-can-i-use-windows-powershell-to-automate-microsoft-excel.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CodeRover</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-908</link>
		<dc:creator>CodeRover</dc:creator>
		<pubDate>Thu, 25 Feb 2010 20:21:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-908</guid>
		<description>How can one use PowerShell to replace Carriage Return character in a MS Excel spreadsheet with an empty space?</description>
		<content:encoded><![CDATA[<p>How can one use PowerShell to replace Carriage Return character in a MS Excel spreadsheet with an empty space?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: search</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-857</link>
		<dc:creator>search</dc:creator>
		<pubDate>Fri, 01 Jan 2010 22:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-857</guid>
		<description>Search and replace should be a basic feature for a lot of things. I see lots of applications not even providing this feature, which is pull your hair out frustrating.</description>
		<content:encoded><![CDATA[<p>Search and replace should be a basic feature for a lot of things. I see lots of applications not even providing this feature, which is pull your hair out frustrating.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Byteway</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-734</link>
		<dc:creator>Byteway</dc:creator>
		<pubDate>Mon, 24 Aug 2009 13:28:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-734</guid>
		<description>How can I replace (special characters) within a servicename the &quot;$&quot; sign for a &quot;?&quot;. When I escape the $ character within the service name, it is not accepted:
$servicename = AOS$01 
stop-Service $servicename (this returns errors: service name can not be found)

Changing the servicename to:
$servicename = AOS\$01 
$servicename = AOS&#039;$01 
does not work ???

Please can you give a tip on how to solve this?

Regards,
Byteway</description>
		<content:encoded><![CDATA[<p>How can I replace (special characters) within a servicename the &#8220;$&#8221; sign for a &#8220;?&#8221;. When I escape the $ character within the service name, it is not accepted:<br />
$servicename = AOS$01<br />
stop-Service $servicename (this returns errors: service name can not be found)</p>
<p>Changing the servicename to:<br />
$servicename = AOS\$01<br />
$servicename = AOS&#8217;$01<br />
does not work ???</p>
<p>Please can you give a tip on how to solve this?</p>
<p>Regards,<br />
Byteway</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: moshe ro</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-538</link>
		<dc:creator>moshe ro</dc:creator>
		<pubDate>Mon, 22 Dec 2008 15:25:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-538</guid>
		<description>Hi,
Exactly what I need :
I wrote a PS script that contain a lot of string replacements in files ,and your function Replace-String made it simple and readable.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Exactly what I need :<br />
I wrote a PS script that contain a lot of string replacements in files ,and your function Replace-String made it simple and readable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-55</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 17 Apr 2008 12:10:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-55</guid>
		<description>Hi there ;)

Just what I needed. I think that you may also ommit the first cmdlet (get-childitem) and incorporate it into select-string using the the -path option. Just my two cents ;)</description>
		<content:encoded><![CDATA[<p>Hi there <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Just what I needed. I think that you may also ommit the first cmdlet (get-childitem) and incorporate it into select-string using the the -path option. Just my two cents <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Refactoring C# with PowerShell &#124; Aaron Lerch</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-54</link>
		<dc:creator>Refactoring C# with PowerShell &#124; Aaron Lerch</dc:creator>
		<pubDate>Fri, 04 Jan 2008 23:09:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-54</guid>
		<description>[...] Note that this function relies on my &#8220;Replace-String&#8221; function, found here. [...]</description>
		<content:encoded><![CDATA[<p>[...] Note that this function relies on my &#8220;Replace-String&#8221; function, found here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Refactoring C# with PowerShell - Aaron Lerch</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-53</link>
		<dc:creator>Refactoring C# with PowerShell - Aaron Lerch</dc:creator>
		<pubDate>Fri, 04 Jan 2008 23:06:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-53</guid>
		<description>[...] Note that this function relies on my &quot;Replace-String&quot; function, found here. [...]</description>
		<content:encoded><![CDATA[<p>[...] Note that this function relies on my &quot;Replace-String&quot; function, found here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aaron</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-51</link>
		<dc:creator>aaron</dc:creator>
		<pubDate>Wed, 22 Aug 2007 23:29:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-51</guid>
		<description>Good point, it&#039;s a messy solution, but sometimes it&#039;s what we have to do. :)</description>
		<content:encoded><![CDATA[<p>Good point, it&#8217;s a messy solution, but sometimes it&#8217;s what we have to do. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: schallm</title>
		<link>http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/comment-page-1/#comment-52</link>
		<dc:creator>schallm</dc:creator>
		<pubDate>Wed, 22 Aug 2007 23:29:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2007/03/28/powershell-replace-string-function/#comment-52</guid>
		<description>This code/function works for simple regular expressions, but if you need to replace across lines it will not work.  Unfortunately I can&#039;t seem to get Select-String to work across lines, so you would need to have a $narrow as well as a $find.  The @narrow would be a single line regex that would narrow the number of files you would perform the full $find regex on.  Here is updated code.  This will read the whole file into a string, so it may use a chunk of memory for large files...&lt;BR/&gt;&lt;BR/&gt;Get-ChildItem $includes &#124; Select-String $narrow -list &#124; % { [string]::join(&quot;`n&quot;, (Get-Content $_.Path)) -replace $find, $replace &#124; set-content $_.Path }</description>
		<content:encoded><![CDATA[<p>This code/function works for simple regular expressions, but if you need to replace across lines it will not work.  Unfortunately I can&#8217;t seem to get Select-String to work across lines, so you would need to have a $narrow as well as a $find.  The @narrow would be a single line regex that would narrow the number of files you would perform the full $find regex on.  Here is updated code.  This will read the whole file into a string, so it may use a chunk of memory for large files&#8230;</p>
<p>Get-ChildItem $includes | Select-String $narrow -list | % { [string]::join(&#8220;`n&#8221;, (Get-Content $_.Path)) -replace $find, $replace | set-content $_.Path }</p>
]]></content:encoded>
	</item>
</channel>
</rss>

