<?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>Software Warlock &#187; Scripting</title>
	<atom:link href="http://softwareblog.morlok.net/category/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://softwareblog.morlok.net</link>
	<description></description>
	<lastBuildDate>Sat, 10 Jul 2010 15:34:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PowerShell Import-Csv Error</title>
		<link>http://softwareblog.morlok.net/2009/04/17/powershell-import-csv-error/</link>
		<comments>http://softwareblog.morlok.net/2009/04/17/powershell-import-csv-error/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 22:31:38 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Import-Csv]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=188</guid>
		<description><![CDATA[
I ran across the following error while working with a PowerShell script I was developing:


Import-Csv : Cannot process argument because the value of argument "name" is invalid.
Change the value of the "name" argument and run the operation again.


It had me stumped for a while.  The Impor-Csv command was failing, but the file name was [...]]]></description>
			<content:encoded><![CDATA[<p>
I ran across the following error while working with a PowerShell script I was developing:
</p>
<pre style="color: red;">
Import-Csv : Cannot process argument because the value of argument "name" is invalid.
Change the value of the "name" argument and run the operation again.
</pre>
<p>
It had me stumped for a while.  The <a href="http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/import-csv.mspx">Impor-Csv</a> command was failing, but the file name was good (I could cat the files contents to standard out).
</p>
<p>
Long story short, the error came from having trailing blank columns in my CSV.  Import-Csv uses the first row in the CSV as names for the columns (unless you specify otherwise) and when you have blank columns (or at least multiple blank columns) it causes this error as it doesn&#8217;t have a valid name for them.  The underlying culprit for the error was actually Microsoft Excel.  I was exporting a spreadsheet to a CSV and the spreadsheet had previously had some trailing columns.  I values to the columns, but apparently Excel decided they should still show up in the export.  Fully deleting the columns so they didn&#8217;t show up in the CSV resolved the problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2009/04/17/powershell-import-csv-error/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Customizing Your Powershell Prompt</title>
		<link>http://softwareblog.morlok.net/2009/03/30/customizing-your-powershell-prompt/</link>
		<comments>http://softwareblog.morlok.net/2009/03/30/customizing-your-powershell-prompt/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 02:52:52 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=127</guid>
		<description><![CDATA[
Powershell is a great CLI for Windows and I appreciate it&#8217;s design more and more every time I use it.  As I interactive with for more and more tasks, wanted to customize it a bit so that it looked prettier, and so I could visually distinguish what was going on more easily.



One thing I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>
Powershell is a great CLI for Windows and I appreciate it&#8217;s design more and more every time I use it.  As I interactive with for more and more tasks, wanted to customize it a bit so that it looked prettier, and so I could visually distinguish what was going on more easily.
</p>
<p><a href="http://softwareblog.morlok.net/wp-content/uploads/2009/03/image001.png"><img src="http://softwareblog.morlok.net/wp-content/uploads/2009/03/image001-300x203.png" alt="" title="my prompt" width="300" height="203" class="aligncenter size-medium wp-image-129" /></a></p>
<p>
One thing I&#8217;ve always done in the *NIX world was add color to my prompt so that it would be easy for me to tell where each command/output sequence started and ended.  To do this you need to edit (or create) the file <a href="http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx"><tt>&lt;My Documents&gt;\WindowsPowerShell\Microsoft.PowerShell_profile.ps1</tt></a>
</p>
<p>
To determine how to render the prompt, Powershell calls a function, <tt>prompt</tt>.  To change the appearance, just implement this function in your profile.  Mine is as shown below:
</p>
<pre>
Write-Host -nonewline "Welcome to PowerShell "
Write-Host -nonewline -foregroundcolor Magenta $env:Username
Write-Host "!"
Write-Host " "

function prompt {
            Write-Host -nonewline -foregroundcolor Magenta "PS "
            Write-Host -nonewline -foregroundcolor Green $(get-location)
            Write-Host -nonewline -foregroundcolor Magenta " >"
            " "
}
</pre>
<p>Note that the output uses the <tt>-foregroundcolor</tt> flag with <tt>Write-host</tt> to change the output color.  Also note that built-in variables are used to determine context information, such as the current location.
</p>
<p><a href="http://mshforfun.blogspot.com/2006/05/perfect-prompt-for-windows-powershell.html">This</a> blog post worked a quick reference for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2009/03/30/customizing-your-powershell-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alternative to Regedit</title>
		<link>http://softwareblog.morlok.net/2008/09/22/alternative-to-regedit/</link>
		<comments>http://softwareblog.morlok.net/2008/09/22/alternative-to-regedit/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 17:16:26 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/2008/09/22/alternative-to-regedit/</guid>
		<description><![CDATA[Anyone who spends time on Windows quickly becomes familiar with regedit.  It&#8217;s the fastest way to to get at a lot of configuration information and set specific application/OS flags.
When working from the command line, however, the reg command can be a better alternative for use in .BAT scripts.  The reg command is specifically [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who spends time on Windows quickly becomes familiar with regedit.  It&#8217;s the fastest way to to get at a lot of configuration information and set specific application/OS flags.</p>
<p>When working from the command line, however, the <em>reg</em> command can be a better alternative for use in .BAT scripts.  The reg command is specifically designed for scripting, and can do things like compare registry keys, retrieve key values, import/export .reg files, and much more.  The help output of the command is listed below.</p>
<pre>
C:\Documents and Settings\Foo>reg /?

Console Registry Tool for Windows - version 3.0
Copyright (C) Microsoft Corp. 1981-2001.  All rights reserved

REG Operation [Parameter List]

  Operation  [ QUERY   | ADD    | DELETE  | COPY    |
               SAVE    | LOAD   | UNLOAD  | RESTORE |
               COMPARE | EXPORT | IMPORT ]

Return Code: (Except of REG COMPARE)

  0 - Succussful
  1 - Failed

For help on a specific operation type:

  REG Operation /?

Examples:

  REG QUERY /?
  REG ADD /?
  REG DELETE /?
  REG COPY /?
  REG SAVE /?
  REG RESTORE /?
  REG LOAD /?
  REG UNLOAD /?
  REG COMPARE /?
  REG EXPORT /?
  REG IMPORT /?
</pre>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2008/09/22/alternative-to-regedit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
