<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Edwin M SarmientoAnother one-liner in Windows PowerShell &#8211; Edwin M Sarmiento</title>
	<atom:link href="https://www.edwinmsarmiento.com/another-one-liner-in-windows-powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.edwinmsarmiento.com</link>
	<description>Intentional Excellence</description>
	<lastBuildDate>Mon, 13 Apr 2026 21:00:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">84283043</site>		<item>
		<title>Another one-liner in Windows PowerShell</title>
		<link>https://www.edwinmsarmiento.com/another-one-liner-in-windows-powershell/</link>
		<comments>https://www.edwinmsarmiento.com/another-one-liner-in-windows-powershell/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 03:47:00 +0000</pubDate>
		<dc:creator>Edwin M Sarmiento</dc:creator>
				<category><![CDATA[read files]]></category>
		<category><![CDATA[Windows PowerShell]]></category>
		<guid isPermaLink="false">http://bassplayerdoc.wordpress.com/2008/10/30/another-one-liner-in-windows-powershell</guid>

				<description><![CDATA[I did mention that I have been trying to convert my VBScript files to PowerShell scripts due to ease of coding. One of them happened to be a script that iterates a folder containing logs, reads the contents of the log files and appends them to a text file (I was actually trying to consolidate [&#8230;]]]></description>
					<content:encoded><![CDATA[<p><span style="font-family:arial;">I did mention that I have been trying to convert my VBScript files to PowerShell scripts due to ease of coding. One of them happened to be a script that iterates a folder containing logs, reads the contents of the log files and appends them to a text file (I was actually trying to consolidate all the RADIUS logs for parsing and storage in a database). In VBScript, here&#8217;s how it is written</span></p>
<p><strong><em><span style="font-size:85%;color:#000099;">Const ForReading = 1</span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)</span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">Set folder = objFSO.GetFolder(&#8220;d:a&#8221;)</span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">Set outfile = objFSO.CreateTextFile(&#8220;d:testout.txt&#8221;)<br />
</span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">for each file in folder.Files<br />
Set testfile = objFSO.OpenTextFile(file.path, ForReading)<br />
Do While Not testfile.AtEndOfStream </span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">line=testfile.ReadLine </span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">&#8216;write to a single output file </span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">outfile.writeline(line)<br />
Loop<br />
testfile.close<br />
Next<br />
</span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">outfile.close<br />
Set objFSO = Nothing</span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">Set folder = Nothing</span></em></strong><br />
<strong><em><span style="font-size:85%;color:#000099;">Set outfile = Nothing</span></em></strong></p>
<p><span style="font-family:arial;">Here&#8217;s how you can do it in PowerShell &#8211; with the cmdlet aliases</span></p>
<pre class="brush: powershell; title: ; notranslate">

ls d:a gc ac d:testout.txt

</pre>
<p><span style="font-family:arial;">This should be more than enough reason to learn PowerShell as a system administrator. More to come</span></p>
<div class="blogger-post-footer"></div>
]]></content:encoded>
			

		<wfw:commentRss>https://www.edwinmsarmiento.com/another-one-liner-in-windows-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
				<post-id xmlns="com-wordpress:feed-additions:1">142</post-id>	</item>
	</channel>
</rss>