<?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: A guide to PowerShell&#8217;s Advanced Functions</title>
	<atom:link href="http://huddledmasses.org/a-guide-to-advanced-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org/a-guide-to-advanced-functions/</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Mon, 15 Mar 2010 20:36:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Stuart Henderson</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212337</link>
		<dc:creator>Stuart Henderson</dc:creator>
		<pubDate>Tue, 10 Mar 2009 20:47:25 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212337</guid>
		<description>Hi Jaykul,

I think it was I who posted the message in the NG asking for clarification.

As usual you come through with something far exceeding what I could have hoped for. I can&#039;t thank you enough for the help you have provided me both in the NG and the IRC.

I&#039;m gonna email Jeffrey Snover every week till he gives you the MVP and backdates it a year Haha!!

Thanks again,
Stuart</description>
		<content:encoded><![CDATA[<p>Hi Jaykul,</p>
<p>I think it was I who posted the message in the NG asking for clarification.</p>
<p>As usual you come through with something far exceeding what I could have hoped for. I can&#8217;t thank you enough for the help you have provided me both in the NG and the <span class="caps">IRC</span>.</p>
<p>I&#8217;m gonna email Jeffrey Snover every week till he gives you the <span class="caps">MVP</span> and backdates it a year Haha!!</p>
<p>Thanks again,<br />
Stuart</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel 'Jaykul' Bennett</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212315</link>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
		<pubDate>Wed, 04 Mar 2009 13:57:52 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212315</guid>
		<description>Yeah, that&#039;s probably because @$PWD -ne [Environment]::CurrentDirectory@

If you want it to be, you should add a line to your prompt function to set it: @[Environment]::CurrentDirectory = $pwd@</description>
		<content:encoded><![CDATA[<p>Yeah, that&#8217;s probably because <code>$PWD -ne [Environment]::CurrentDirectory</code></p>
<p>If you want it to be, you should add a line to your prompt function to set it: <code>[Environment]::CurrentDirectory = $pwd</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Klaus Schulte</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212313</link>
		<dc:creator>Klaus Schulte</dc:creator>
		<pubDate>Wed, 04 Mar 2009 07:39:27 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212313</guid>
		<description></description>
		<content:encoded><![CDATA[<p>Hello Joel,</p>
<p>thank you very much for your reply!<br />
I won&#8217;t argue any more &#8230; but I&#8217;d like to add these lines and finish the discussion anyway. Things are sometimes not the way they should be and I can live with that <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<div class="posh code posh" style="font-family:monospace;">
<span style="color: #666666; font-style: italic;"># A credential object: $c was created</span><br />
<span style="color: #660033;">PS</span> <span style="color: #660033;">H</span>:\Powershell<span style="color: #66cc66;">&gt;</span> <span style="color: #660033; font-weight: bold;">$c</span></p>
<p>UserName &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Password<br />
DOMS\schulte &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">System</span>.<span style="color: #003366;">Security</span>.<span style="color: #003366;">SecureString</span></p>
<p><span style="color: #666666; font-style: italic;"># My CurrentDirectory is writeable (and readable) by my account</span><br />
<span style="color: #660033;">PS</span> <span style="color: #660033;">H</span>:\Powershell<span style="color: #66cc66;">&gt;</span> <span style="color: #0066cc; font-style: italic;">out-<span style="font-style: normal;">file</span></span> <span style="color: #000066;">-inp</span> <span style="color: #009900;">&quot;I can write to $([Environment]::CurrentDirectory)!&quot;</span> <span style="color: #009900;">&quot;$([Environment]::CurrentDirectory)\WriteToMe.txt&quot;</span></p>
<p><span style="color: #666666; font-style: italic;"># I CAN'T start a process with my Credentials:</span><br />
<span style="color: #660033;">PS</span> <span style="color: #660033;">H</span>:\Powershell<span style="color: #66cc66;">&gt;</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">System</span>.<span style="color: #003366;">Diagnostics</span>.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;Notepad&quot;</span>, <span style="color: #660033; font-weight: bold;">$c</span>.<span style="color: #003366;">GetNetworkCredential</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span>.<span style="color: #003366;">UserName</span>, <span style="color: #660033; font-weight: bold;">$c</span>.<span style="color: #003366;">Password</span>, <span style="color: #660033; font-weight: bold;">$c</span>.<span style="color: #003366;">GetNetworkCredential</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span>.<span style="color: #003366;">Domain</span><span style="color: #333;">&#41;</span></p>
<p>Exception calling <span style="color: #009900;">&quot;Start&quot;</span> with <span style="color: #009900;">&quot;4&quot;</span> argument<span style="color: #333;">&#40;</span>s<span style="color: #333;">&#41;</span>: <span style="color: #009900;">&quot;Der Verzeichnisname ist ungültig&quot;</span><br />
At line:<span style="color: #cc66cc;">1</span> <span style="color: #003366; font-weight: bold;">char</span>:<span style="color: #cc66cc;">36</span><br />
<span style="color: #66cc66;">+</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">System</span>.<span style="color: #003366;">Diagnostics</span>.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span> <span style="color: #66cc66;">&amp;</span>lt;<span style="color: #66cc66;">&amp;</span>lt;<span style="color: #66cc66;">&amp;</span>lt; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">System</span>.<span style="color: #003366;">Diagnostics</span>.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;Notepad&quot;</span><span style="color: #333;">&#41;</span></p>
<p>Handles &nbsp;NPM<span style="color: #333;">&#40;</span>K<span style="color: #333;">&#41;</span> &nbsp; &nbsp;PM<span style="color: #333;">&#40;</span>K<span style="color: #333;">&#41;</span> &nbsp; &nbsp; &nbsp;WS<span style="color: #333;">&#40;</span>K<span style="color: #333;">&#41;</span> VM<span style="color: #333;">&#40;</span>M<span style="color: #333;">&#41;</span> &nbsp; CPU<span style="color: #333;">&#40;</span>s<span style="color: #333;">&#41;</span> &nbsp; &nbsp; Id ProcessName &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #66cc66;">-------</span> &nbsp;<span style="color: #66cc66;">------</span> &nbsp; &nbsp;<span style="color: #66cc66;">-----</span> &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">-----</span> <span style="color: #66cc66;">-----</span> &nbsp; <span style="color: #66cc66;">------</span> &nbsp; &nbsp; <span style="color: #66cc66;">--</span> <span style="color: #66cc66;">-----------</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">0</span> &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">0</span> &nbsp; &nbsp; &nbsp;<span style="color: #cc66cc;">140</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">84</span> &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> &nbsp; &nbsp; <span style="color: #cc66cc;">0</span>,02 &nbsp; <span style="color: #cc66cc;">4304</span> notepad &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;</div>
<ul>
<li>Life is <span class="caps">NOT</span> <span class="caps">ALWAYS</span> dair ******</li>
</ul>
<p>
kind regards, Klaus</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel 'Jaykul' Bennett</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212308</link>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
		<pubDate>Tue, 03 Mar 2009 22:19:56 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212308</guid>
		<description>Klaus: I haven&#039;t seen that invalid working directory exception ... you must be trying to start the process with an account that doesn&#039;t have rights to the folder you&#039;re in.

When you launch an app without specifying the Working Directory, it will be set to @[Environment]::CurrentDirectory@ ... if you use an account that can&#039;t access that folder, you will get a Win32Exception &quot;The directory name is invalid&quot; (in English).  The simplest solution is to set your CurrentDirectory, but as you discovered, it also works to use the ProcessStartInfo -- which holds many other powers too :D</description>
		<content:encoded><![CDATA[<p>Klaus: I haven&#8217;t seen that invalid working directory exception &#8230; you must be trying to start the process with an account that doesn&#8217;t have rights to the folder you&#8217;re in.</p>
<p>When you launch an app without specifying the Working Directory, it will be set to <code>[Environment]::CurrentDirectory</code> &#8230; if you use an account that can&#8217;t access that folder, you will get a Win32Exception &#8220;The directory name is invalid&#8221; (in English).  The simplest solution is to set your CurrentDirectory, but as you discovered, it also works to use the ProcessStartInfo &#8212; which holds many other powers too <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel 'Jaykul' Bennett</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212306</link>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
		<pubDate>Tue, 03 Mar 2009 21:51:16 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212306</guid>
		<description>chad: good catch</description>
		<content:encoded><![CDATA[<p>chad: good catch</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Miller</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212305</link>
		<dc:creator>Chad Miller</dc:creator>
		<pubDate>Tue, 03 Mar 2009 17:36:38 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212305</guid>
		<description>Modules and Advanced functions seem a lot clearer to me now --Thanks for the guide. 

I&#039;ve also heard the term &quot;library&quot; used to describe function(s) which you source. Should &quot;processutility.ps1&quot; be &quot;processutility.psm1&quot; in 4a?</description>
		<content:encoded><![CDATA[<p>Modules and Advanced functions seem a lot clearer to me now &#8212;Thanks for the guide. </p>
<p>I&#8217;ve also heard the term &#8220;library&#8221; used to describe function(s) which you source. Should &#8220;processutility.ps1&#8221; be &#8220;processutility.psm1&#8221; in 4a?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Archer</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212304</link>
		<dc:creator>Jason Archer</dc:creator>
		<pubDate>Tue, 03 Mar 2009 17:35:53 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212304</guid>
		<description>Thank you for writing this up, it was sorely needed.</description>
		<content:encoded><![CDATA[<p>Thank you for writing this up, it was sorely needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Mohundro</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212301</link>
		<dc:creator>David Mohundro</dc:creator>
		<pubDate>Tue, 03 Mar 2009 14:15:26 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212301</guid>
		<description>Apparently I don&#039;t even know my openid URL. Sorry about messing up that last comment.</description>
		<content:encoded><![CDATA[<p>Apparently I don&#8217;t even know my openid <span class="caps">URL</span>. Sorry about messing up that last comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Mohundro</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212300</link>
		<dc:creator>David Mohundro</dc:creator>
		<pubDate>Tue, 03 Mar 2009 14:09:33 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212300</guid>
		<description>Nice guide - thanks for posting it! I really haven&#039;t been taking advantage of what&#039;s possible with advanced functions. So far, I&#039;ve primarily been using it to require parameters (with [Parameter(Mandatory=$true)]). I need to try some more features out.</description>
		<content:encoded><![CDATA[<p>Nice guide &#8211; thanks for posting it! I really haven&#8217;t been taking advantage of what&#8217;s possible with advanced functions. So far, I&#8217;ve primarily been using it to require parameters (with [Parameter(Mandatory=$true)]). I need to try some more features out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Klaus Schulte</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/comment-page-1/#comment-212299</link>
		<dc:creator>Klaus Schulte</dc:creator>
		<pubDate>Tue, 03 Mar 2009 13:18:34 +0000</pubDate>
		<guid isPermaLink="false">http://huddledmasses.org/?p=1116#comment-212299</guid>
		<description></description>
		<content:encoded><![CDATA[<p>Dear Joel,</p>
<p>firstOfAll: thank you very much for your powershell guides!!!<br />
I love to read through them &#8230; (if I&#8217;ve got the time) ...</p>
<p>Just one question and a short comment:</p>
<p>1) You specified: DefaultParameterSetName=&#8220;NoCreds&#8221;<br />
I&#8217;m no PS-expert &#8230; but shouldn&#8217;t there be a ParameterSet with the tag &#8220;NoCred&#8221; defined somewhere in the param-section?</p>
<p>2)  If I try to start a process with:</p>
<div class="posh code posh" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;notepad.exe&quot;</span>, <span style="color: #660033; font-weight: bold;">$c</span>.<span style="color: #003366;">GetNetworkCredential</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span>.<span style="color: #003366;">UserName</span>, <span style="color: #660033; font-weight: bold;">$c</span>.<span style="color: #003366;">Password</span>, <span style="color: #660033; font-weight: bold;">$c</span>.<span style="color: #003366;">GetNetworkCredential</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span>.<span style="color: #003366;">Domain</span><span style="color: #333;">&#41;</span></div>
<p>... that&#8217;s what your adv.function will issue, if I add a parameter ( $c = get-Credential ) to the call: <br />
&#8220;Start-Process &#8220;notepad.exe&#8221; -Credential $c&#8221;<br />
I&#8217;m receiving an exception </p>
<p>PS C:\Dokumente und Einstellungen\Schulte&gt; Start-Process &#8220;notepad.exe&#8221; -Credential $c<br />
Exception calling &#8220;Start&#8221; with &#8220;4&#8221; argument(s): &#8220;Der Verzeichnisname ist ungültig&#8221;<br />
At H:\Powershell\Start-Process.ps1:38 char:35<br />
+       [Diagnostics.Process]::Start &lt;&lt;&lt;&lt; (<br />
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException<br />
    + FullyQualifiedErrorId : DotNetMethodException</p>
<p>That exception ( in english: &#8220;invalid directory name&#8221; ) occurs only, if I add the Credentials to the call. This works:<br />
Start-Process &#8220;notepad.exe&#8221;  </p>
<p>As I figured out, that&#8217;s a problem with the &#8220;working directory&#8221;, that you can set explicitly using the &#8220;StartProcessInfo&#8221; parameter as an overload to the Start method. Using C# this works:</p>
<div class="csharp code csharp" style="font-family:monospace;"><span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span>.<span style="color: #0000FF;">ProcessStartInfo</span> psi <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span>.<span style="color: #0000FF;">ProcessStartInfo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
psi.<span style="color: #0000FF;">Arguments</span> <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span><br />
psi.<span style="color: #0000FF;">Domain</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;MyDomain&quot;</span><span style="color: #008000;">;</span><br />
psi.<span style="color: #0000FF;">FileName</span> <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;c:\windows\System32\Notepad.exe&quot;</span><span style="color: #008000;">;</span><br />
psi.<span style="color: #0000FF;">Password</span> <span style="color: #008000;">=</span> pwd<span style="color: #008000;">;</span><br />
psi.<span style="color: #0000FF;">UserName</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;UserName&quot;</span><span style="color: #008000;">;</span><br />
psi.<span style="color: #0000FF;">UseShellExecute</span> <span style="color: #008000;">=</span> false<span style="color: #008000;">;</span><br />
psi.<span style="color: #0000FF;">WorkingDirectory</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;C:<span style="color: #008080; font-weight: bold;">\</span>&quot;</span><span style="color: #008000;">;</span><br />
<span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span>.<span style="color: #0000FF;">Process</span>.<span style="color: #0000FF;">Start</span><span style="color: #000000;">&#40;</span>psi<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></div>
<p>Commenting out the psi.WorkingDirectory line results in the &#8220;invalid directory&#8221; exception!</p>
<p>Strange but true <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>king regards, Klaus</p>
]]></content:encoded>
	</item>
</channel>
</rss>
