<?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: Organizing Script Code &#8211; Calling Scripts from Other Script Files</title>
	<atom:link href="http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/</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: Mark B Smith</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-471</link>
		<dc:creator>Mark B Smith</dc:creator>
		<pubDate>Thu, 22 Apr 2010 02:17:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-471</guid>
		<description>Great article got me upto speed using dot-sourcing.

Found an issue though using this method as I wanted to pass a path via a variable but it would fail.

. {&quot;$scriptpath\runme.ps1&quot;}

Wouldn&#039;t work with or without quotes, but found a simple solution which was to remove the braces.

. $Scriptpath\runme.ps1

Pretty obvious I guess but it stumped me for awhile so thought others may benefit. :)

Thx
Mark

Cheers
Mark</description>
		<content:encoded><![CDATA[<p>Great article got me upto speed using dot-sourcing.</p>
<p>Found an issue though using this method as I wanted to pass a path via a variable but it would fail.</p>
<p>. {&#8220;$scriptpath\runme.ps1&#8243;}</p>
<p>Wouldn&#8217;t work with or without quotes, but found a simple solution which was to remove the braces.</p>
<p>. $Scriptpath\runme.ps1</p>
<p>Pretty obvious I guess but it stumped me for awhile so thought others may benefit. <img src='http://www.powershellpro.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thx<br />
Mark</p>
<p>Cheers<br />
Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vidya</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-460</link>
		<dc:creator>Vidya</dc:creator>
		<pubDate>Wed, 24 Mar 2010 08:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-460</guid>
		<description>Mr. Trotter,

I got the solution. Incase if anybody is looking for it.
invoke-expression $variable-name</description>
		<content:encoded><![CDATA[<p>Mr. Trotter,</p>
<p>I got the solution. Incase if anybody is looking for it.<br />
invoke-expression $variable-name</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vidya</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-459</link>
		<dc:creator>Vidya</dc:creator>
		<pubDate>Wed, 24 Mar 2010 07:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-459</guid>
		<description>Hello Mr. Trotter,

I am looking out for exactly what you have asked for. Did you find the solution to this further. Is there anything like shell object.Run &quot;$sScript&quot; as we have in vbscript. 
Please put down the solution if you have found one.</description>
		<content:encoded><![CDATA[<p>Hello Mr. Trotter,</p>
<p>I am looking out for exactly what you have asked for. Did you find the solution to this further. Is there anything like shell object.Run &#8220;$sScript&#8221; as we have in vbscript.<br />
Please put down the solution if you have found one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc Trotter</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-452</link>
		<dc:creator>Marc Trotter</dc:creator>
		<pubDate>Sat, 13 Mar 2010 18:57:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-452</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: PS</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-116</link>
		<dc:creator>PS</dc:creator>
		<pubDate>Mon, 26 May 2008 18:03:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-116</guid>
		<description>People, this doesn&#039;t work! I&#039;m trying to work on something completely different but it needs to utilize functions in different ps1 files and it doesn&#039;t work. So I decided that I&#039;m doing something wrong and I&#039;m copying/pasting the entire code as displayed here and Powershell still cannot find those functions. You have my email if you care to help me &#039;see the light&#039; or if you want to &#039;see the light&#039; yourselves.</description>
		<content:encoded><![CDATA[<p>People, this doesn&#8217;t work! I&#8217;m trying to work on something completely different but it needs to utilize functions in different ps1 files and it doesn&#8217;t work. So I decided that I&#8217;m doing something wrong and I&#8217;m copying/pasting the entire code as displayed here and Powershell still cannot find those functions. You have my email if you care to help me &#8217;see the light&#8217; or if you want to &#8217;see the light&#8217; yourselves.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse Hamrick</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-90</link>
		<dc:creator>Jesse Hamrick</dc:creator>
		<pubDate>Tue, 15 Apr 2008 17:07:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-90</guid>
		<description>This is how to do what Kevin is describing...
http://www.powershellpro.com/function-calling/144/</description>
		<content:encoded><![CDATA[<p>This is how to do what Kevin is describing&#8230;<br />
<a href="http://www.powershellpro.com/function-calling/144/" rel="nofollow">http://www.powershellpro.com/function-calling/144/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon M</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-88</link>
		<dc:creator>Simon M</dc:creator>
		<pubDate>Tue, 15 Apr 2008 13:26:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-88</guid>
		<description>Kevin, thats a superb tip, exactly what I needed, thanks!</description>
		<content:encoded><![CDATA[<p>Kevin, thats a superb tip, exactly what I needed, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Tearle</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-21</link>
		<dc:creator>Andy Tearle</dc:creator>
		<pubDate>Thu, 18 Oct 2007 03:17:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-21</guid>
		<description>Thanx !</description>
		<content:encoded><![CDATA[<p>Thanx !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/comment-page-1/#comment-17</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Mon, 08 Oct 2007 18:10:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/organizing-powershell-script-code-is-a-snap-in/102/#comment-17</guid>
		<description>I would recommend that instead of having a large number of snippets that you actually insert into the main body of the script, that you dot source the functions (it will use the System&#039;s path to find the .ps1 files if necessary).  This way the size of the individual script stays down and you can update/optimize your functions and all of the scripts calling them will immediately benefit.</description>
		<content:encoded><![CDATA[<p>I would recommend that instead of having a large number of snippets that you actually insert into the main body of the script, that you dot source the functions (it will use the System&#8217;s path to find the .ps1 files if necessary).  This way the size of the individual script stays down and you can update/optimize your functions and all of the scripts calling them will immediately benefit.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
