<?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: Why would I want to call a function that exists in a separate script?</title>
	<atom:link href="http://www.powershellpro.com/function-calling/144/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.powershellpro.com/function-calling/144/</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: Eric Duncan</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-470</link>
		<dc:creator>Eric Duncan</dc:creator>
		<pubDate>Fri, 09 Apr 2010 18:44:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-470</guid>
		<description>This is great but I have an issue: Using the example above, the first script (which has the function) also launches a new powershell.exe instance, the second script in the new instance does not seem to be able to call the function in the first script. Is there a way around this?</description>
		<content:encoded><![CDATA[<p>This is great but I have an issue: Using the example above, the first script (which has the function) also launches a new powershell.exe instance, the second script in the new instance does not seem to be able to call the function in the first script. Is there a way around this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc Trotter</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-451</link>
		<dc:creator>Marc Trotter</dc:creator>
		<pubDate>Sat, 13 Mar 2010 18:56:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-451</guid>
		<description>Is there a way to loop through subfolders and call a script named run.ps1 from below each folder.  I&#039;m fairly new to powershell and can&#039;t get this to work. As presently written it simply treats the file as a literal string, not really what I&#039;m after.

I want to place a script and all supporting files in a subfolder and then loop through each subfolder and call run.ps1.  This is what I presently do with CMD files, that way when I no longer need a module we just delete the folder.  Similarly if I need to add a module I just drop in a new folder.  I don&#039;t want to edit the calling script, if I can avoid it.

Here&#039;s what I have:

   $list = Get-ChildItem C:\APPS\SCRIPTS -exclude maintenance.ps1 &#124; Sort-Object Name
   
   foreach ($i in $list)
      {
         Write-Host &quot;Processing &quot; $i&quot;...&quot;
         $sScript = [STRING]$i + &quot;\run.ps1&quot;
       # this line works
         .{c:\apps\scripts00_Critical\run.ps1}
       # this line doesn&#039;t work
         .{$sScript}
      }</description>
		<content:encoded><![CDATA[<p>Is there a way to loop through subfolders and call a script named run.ps1 from below each folder.  I&#8217;m fairly new to powershell and can&#8217;t get this to work. As presently written it simply treats the file as a literal string, not really what I&#8217;m after.</p>
<p>I want to place a script and all supporting files in a subfolder and then loop through each subfolder and call run.ps1.  This is what I presently do with CMD files, that way when I no longer need a module we just delete the folder.  Similarly if I need to add a module I just drop in a new folder.  I don&#8217;t want to edit the calling script, if I can avoid it.</p>
<p>Here&#8217;s what I have:</p>
<p>   $list = Get-ChildItem C:\APPS\SCRIPTS -exclude maintenance.ps1 | Sort-Object Name</p>
<p>   foreach ($i in $list)<br />
      {<br />
         Write-Host &#8220;Processing &#8221; $i&#8221;&#8230;&#8221;<br />
         $sScript = [STRING]$i + &#8220;\run.ps1&#8243;<br />
       # this line works<br />
         .{c:\apps\scripts00_Critical\run.ps1}<br />
       # this line doesn&#8217;t work<br />
         .{$sScript}<br />
      }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mostafa Mokhtar</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-414</link>
		<dc:creator>Mostafa Mokhtar</dc:creator>
		<pubDate>Thu, 15 Oct 2009 02:12:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-414</guid>
		<description>Hi

I wanted to know how to call powershell functions that I wrote asynchronously?
any ideas?</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>I wanted to know how to call powershell functions that I wrote asynchronously?<br />
any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Allen</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-382</link>
		<dc:creator>Chris Allen</dc:creator>
		<pubDate>Fri, 24 Jul 2009 18:13:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-382</guid>
		<description>Ok, I do have a question after all.

Is it possible to call a dot source file from a UNC?</description>
		<content:encoded><![CDATA[<p>Ok, I do have a question after all.</p>
<p>Is it possible to call a dot source file from a UNC?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Allen</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-381</link>
		<dc:creator>Chris Allen</dc:creator>
		<pubDate>Fri, 24 Jul 2009 15:27:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-381</guid>
		<description>Never mind. I figured it out. With dot sourcing, the functions do not have to be absolute top of the script.

As a test, I created the function file below with a simple get-mailbox shortcut called getMB.

Then created a script called test.ps1 which looks as follows:

Param($lanid)
. C:\MYScripts\Functions.ps1
getmb $lanid

Putting the Param before the dot source call works perfectly. I ran .\Test -lanid dude123 and it returned the proper results.</description>
		<content:encoded><![CDATA[<p>Never mind. I figured it out. With dot sourcing, the functions do not have to be absolute top of the script.</p>
<p>As a test, I created the function file below with a simple get-mailbox shortcut called getMB.</p>
<p>Then created a script called test.ps1 which looks as follows:</p>
<p>Param($lanid)<br />
. C:\MYScripts\Functions.ps1<br />
getmb $lanid</p>
<p>Putting the Param before the dot source call works perfectly. I ran .\Test -lanid dude123 and it returned the proper results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Allen</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-380</link>
		<dc:creator>Chris Allen</dc:creator>
		<pubDate>Fri, 24 Jul 2009 15:18:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-380</guid>
		<description>I would like to use dot sourcing to pull from a list of functions, but I would also like to be able to run the script with external parameters. Normally, functions have to be declared at the top of the script as does your Param() statement. These seem to compete with each other. The one that is at the top wins, the other is either ignored or produces an error.

So, If I wanted to pass a parameter into a script (I.E. .\test.ps1 -lanid dude123) how would I be able to use that and still dot source my functions?


. C:\MyScripts\Functions.ps1
Param($lanid)</description>
		<content:encoded><![CDATA[<p>I would like to use dot sourcing to pull from a list of functions, but I would also like to be able to run the script with external parameters. Normally, functions have to be declared at the top of the script as does your Param() statement. These seem to compete with each other. The one that is at the top wins, the other is either ignored or produces an error.</p>
<p>So, If I wanted to pass a parameter into a script (I.E. .\test.ps1 -lanid dude123) how would I be able to use that and still dot source my functions?</p>
<p>. C:\MyScripts\Functions.ps1<br />
Param($lanid)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phghost</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-334</link>
		<dc:creator>phghost</dc:creator>
		<pubDate>Fri, 08 May 2009 22:08:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-334</guid>
		<description>Gracias me ha servido de mucho!!!</description>
		<content:encoded><![CDATA[<p>Gracias me ha servido de mucho!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anatol</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-331</link>
		<dc:creator>Anatol</dc:creator>
		<pubDate>Tue, 05 May 2009 17:36:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-331</guid>
		<description>Yesm hte &quot;. .&quot; thing was stoping me to call the functions. Putting it this way will keep the context open and the functions will remain visible.
Thanks Benjy!

and thatnks for trying to explain to the author.</description>
		<content:encoded><![CDATA[<p>Yesm hte &#8220;. .&#8221; thing was stoping me to call the functions. Putting it this way will keep the context open and the functions will remain visible.<br />
Thanks Benjy!</p>
<p>and thatnks for trying to explain to the author.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-250</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Mon, 10 Nov 2008 22:10:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-250</guid>
		<description>It broke up my example...it would be
&quot;. Functions.ps1&quot; (w/o the quotes)</description>
		<content:encoded><![CDATA[<p>It broke up my example&#8230;it would be<br />
&#8220;. Functions.ps1&#8243; (w/o the quotes)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron</title>
		<link>http://www.powershellpro.com/function-calling/144/comment-page-1/#comment-249</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Mon, 10 Nov 2008 22:09:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/function-calling/144/#comment-249</guid>
		<description>If you wanted to take it one step further for a Functions library, you could put the file in the PSHome dir (usually &quot;C:\WINDOWS\system32\WindowsPowerShell\v1.0&quot; or look at $PSHome) and then you would only have to use &quot;. Functions.ps1&quot; w/o the quotes, of course, and don&#039;t forget the space after the &#039;.&#039; Hope that helps.</description>
		<content:encoded><![CDATA[<p>If you wanted to take it one step further for a Functions library, you could put the file in the PSHome dir (usually &#8220;C:\WINDOWS\system32\WindowsPowerShell\v1.0&#8243; or look at $PSHome) and then you would only have to use &#8220;. Functions.ps1&#8243; w/o the quotes, of course, and don&#8217;t forget the space after the &#8216;.&#8217; Hope that helps.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
