<?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 Functions and Filters &#8211; The basics</title>
	<atom:link href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.powershellpro.com</link>
	<description>Sharing the Experience</description>
	<lastBuildDate>Mon, 06 Sep 2010 23:05:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Sara</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-512</link>
		<dc:creator>Sara</dc:creator>
		<pubDate>Wed, 18 Aug 2010 18:16:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-512</guid>
		<description>Hi,

I get errors running the powershell unless I use a ./ Why???

Thanks.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I get errors running the powershell unless I use a ./ Why???</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juan Trujillo</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-410</link>
		<dc:creator>Juan Trujillo</dc:creator>
		<pubDate>Fri, 09 Oct 2009 17:52:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-410</guid>
		<description>Hi,
Is it possible to get a list of the Custom functions/objects/variables that I have created on my current session ?

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Is it possible to get a list of the Custom functions/objects/variables that I have created on my current session ?</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-394</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Tue, 11 Aug 2009 13:20:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-394</guid>
		<description>Gary:

You probably already figured this out, but the reason why your test script gives seemingly unusual results is that your input is an array.  I.e., the comma is actually an operator which means &quot;this is an array&quot; so when you provide input as &quot;one&quot;, &quot;two&quot; you provided an array.  Since PS is dynamically typed, your first parameter $a got an array, not a scalar.

Similarly, this explains why Jeff&#039;s script worked - he provided 2 scalars since there was no comma separating the input.

The lesson?  Don&#039;t use commas on the command line unless you mean to provide an array.</description>
		<content:encoded><![CDATA[<p>Gary:</p>
<p>You probably already figured this out, but the reason why your test script gives seemingly unusual results is that your input is an array.  I.e., the comma is actually an operator which means &#8220;this is an array&#8221; so when you provide input as &#8220;one&#8221;, &#8220;two&#8221; you provided an array.  Since PS is dynamically typed, your first parameter $a got an array, not a scalar.</p>
<p>Similarly, this explains why Jeff&#8217;s script worked &#8211; he provided 2 scalars since there was no comma separating the input.</p>
<p>The lesson?  Don&#8217;t use commas on the command line unless you mean to provide an array.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quentin</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-374</link>
		<dc:creator>Quentin</dc:creator>
		<pubDate>Wed, 15 Jul 2009 23:02:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-374</guid>
		<description>Seems like there is a short-hand way of creating arrays:

PS &gt; $a=&quot;one&quot;, &quot;two&quot;
PS &gt; $a
one
two
PS &gt; $a[0]
one
PS &gt; $a[1]
two</description>
		<content:encoded><![CDATA[<p>Seems like there is a short-hand way of creating arrays:</p>
<p>PS &gt; $a=&#8221;one&#8221;, &#8220;two&#8221;<br />
PS &gt; $a<br />
one<br />
two<br />
PS &gt; $a[0]<br />
one<br />
PS &gt; $a[1]<br />
two</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-360</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Fri, 19 Jun 2009 20:30:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-360</guid>
		<description>This seems to work:
function Test($a, $b) {Write-Host “a=$a, b=$b”}
Test ”one” “two”

I don&#039;t know why, but powershell seems to dislike the () and , seperators.</description>
		<content:encoded><![CDATA[<p>This seems to work:<br />
function Test($a, $b) {Write-Host “a=$a, b=$b”}<br />
Test ”one” “two”</p>
<p>I don&#8217;t know why, but powershell seems to dislike the () and , seperators.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-223</link>
		<dc:creator>James</dc:creator>
		<pubDate>Mon, 29 Sep 2008 12:52:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-223</guid>
		<description>I&#039;m playing with the following script to find files older than 1 day.

$DateToCompare = (get-date).AddDays(-1)
$logFiles = get-childitem C:\logs -recurse &#124; ? {$_.LastWriteTime -lt $DateToCompare}
foreach ($f in $logfiles){
Write-Host $f.name
}

I can send the results via email, however, I need the name and lastwritetime of each file on a new line in the variable sent to the email function.  In vb it would be something like:

foreach f in fld.files
 fileformat = fileformat &amp; vbcrlf
next
SendMail fileformat

Anyone know how this is done in PS? Cheers J</description>
		<content:encoded><![CDATA[<p>I&#8217;m playing with the following script to find files older than 1 day.</p>
<p>$DateToCompare = (get-date).AddDays(-1)<br />
$logFiles = get-childitem C:\logs -recurse | ? {$_.LastWriteTime -lt $DateToCompare}<br />
foreach ($f in $logfiles){<br />
Write-Host $f.name<br />
}</p>
<p>I can send the results via email, however, I need the name and lastwritetime of each file on a new line in the variable sent to the email function.  In vb it would be something like:</p>
<p>foreach f in fld.files<br />
 fileformat = fileformat &amp; vbcrlf<br />
next<br />
SendMail fileformat</p>
<p>Anyone know how this is done in PS? Cheers J</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-221</link>
		<dc:creator>Gary</dc:creator>
		<pubDate>Mon, 22 Sep 2008 23:34:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-221</guid>
		<description>Can someone explain this odd behavior to me? 

#---
function Test($a, $b) {Write-Host &quot;a=$a, b=$b&quot;}
Test(&quot;one&quot;, &quot;two&quot;)
#---

I would have expected the above to display &quot;a=one, b=two&quot;, but instead it displays &quot;a=one two, b=&quot;.  Why is this?  How would I pass two strings to a function and get the results I expected?</description>
		<content:encoded><![CDATA[<p>Can someone explain this odd behavior to me? </p>
<p>#&#8212;<br />
function Test($a, $b) {Write-Host &#8220;a=$a, b=$b&#8221;}<br />
Test(&#8220;one&#8221;, &#8220;two&#8221;)<br />
#&#8212;</p>
<p>I would have expected the above to display &#8220;a=one, b=two&#8221;, but instead it displays &#8220;a=one two, b=&#8221;.  Why is this?  How would I pass two strings to a function and get the results I expected?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NetGuyDave</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-189</link>
		<dc:creator>NetGuyDave</dc:creator>
		<pubDate>Thu, 14 Aug 2008 18:38:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-189</guid>
		<description>Jesse, thanks for this excellent tutorial.  This is at the perfect level for me, just beginning. Very easy read to get started.  ...on to the next one WMI!!</description>
		<content:encoded><![CDATA[<p>Jesse, thanks for this excellent tutorial.  This is at the perfect level for me, just beginning. Very easy read to get started.  &#8230;on to the next one WMI!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse Hamrick</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-187</link>
		<dc:creator>Jesse Hamrick</dc:creator>
		<pubDate>Wed, 13 Aug 2008 17:34:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-187</guid>
		<description>The issue you are running into is a syntax problem. You are attempting to call a FUNCTION using the syntax for calling another powershell script. Let me give you examples of how to do both:
Calling a script that lives outside the main script.
Test.ps1 code -
Write-Host &quot;Hello World&quot;

Caller.ps1 code -
.{.\test.ps1}

Calling a Function that lives outside the main script.
Test.ps1 code -
function Hello {Write-Host &quot;Hello Nitin&quot;}

Caller.ps1 code -
. .\test.ps1
Hello

Make sure you understand when you are attempting to call a script or a function within a script that live outside the main script. This tutorial talks about calling functions but you have to follow &quot;click here to find out how&quot; link under Example 2. Calling a Function from another script file.</description>
		<content:encoded><![CDATA[<p>The issue you are running into is a syntax problem. You are attempting to call a FUNCTION using the syntax for calling another powershell script. Let me give you examples of how to do both:<br />
Calling a script that lives outside the main script.<br />
Test.ps1 code -<br />
Write-Host &#8220;Hello World&#8221;</p>
<p>Caller.ps1 code -<br />
.{.\test.ps1}</p>
<p>Calling a Function that lives outside the main script.<br />
Test.ps1 code -<br />
function Hello {Write-Host &#8220;Hello Nitin&#8221;}</p>
<p>Caller.ps1 code -<br />
. .\test.ps1<br />
Hello</p>
<p>Make sure you understand when you are attempting to call a script or a function within a script that live outside the main script. This tutorial talks about calling functions but you have to follow &#8220;click here to find out how&#8221; link under Example 2. Calling a Function from another script file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nitin</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/comment-page-1/#comment-173</link>
		<dc:creator>Nitin</dc:creator>
		<pubDate>Sun, 10 Aug 2008 14:50:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-functions-filters/#comment-173</guid>
		<description>I wrote test.ps1 which contains following line -
function Hello-World { Write-Host &quot;Hello World&quot; }

Then, I wrote caller.ps1 which contains following line -
.{&#039;.\test.ps1&#039;}

Both the scripts are in the same folder. When I run caller.ps1 file, it does not show &quot;Hello World&quot; on screen.

Please tell me where I was wrong.</description>
		<content:encoded><![CDATA[<p>I wrote test.ps1 which contains following line -<br />
function Hello-World { Write-Host &#8220;Hello World&#8221; }</p>
<p>Then, I wrote caller.ps1 which contains following line -<br />
.{&#8216;.\test.ps1&#8242;}</p>
<p>Both the scripts are in the same folder. When I run caller.ps1 file, it does not show &#8220;Hello World&#8221; on screen.</p>
<p>Please tell me where I was wrong.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
