<?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>UnearthedMedia&#187; external file</title>
	<atom:link href="http://unearthedmedia.com/tag/external-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://unearthedmedia.com</link>
	<description>Business &#38; Technology</description>
	<lastBuildDate>Thu, 15 Apr 2010 18:46:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Including external powershell scripts</title>
		<link>http://unearthedmedia.com/2009/07/02/powershell_include_external_script/</link>
		<comments>http://unearthedmedia.com/2009/07/02/powershell_include_external_script/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 03:01:29 +0000</pubDate>
		<dc:creator>Kevin Harris</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[absolute path]]></category>
		<category><![CDATA[external file]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[including]]></category>
		<category><![CDATA[powershell scripts]]></category>
		<category><![CDATA[ps1]]></category>
		<category><![CDATA[relative paths]]></category>

		<guid isPermaLink="false">http://unearthedmedia.com/?p=144</guid>
		<description><![CDATA[I struggled getting this to work for quite some time. All the posts I found online made it way confusing so I am going to try to clarify it here. You include external powershell files like so...]]></description>
			<content:encoded><![CDATA[<p>I struggled getting this to work for quite some time. All the posts I found online made it way confusing so I am going to try to clarify it here. You include external powershell files like so<span id="more-144"></span></p>
<p><code>.  C:\mydir\powershellfile.ps1</code></p>
<p>easy enough. The period in the front is like your include statement in other languages and YES there is a space between the period and the C:\. If your include file is in the same directory you can do a relative path like so</p>
<p><code>. .\powershellfile.ps1 (.&lt;space&gt;.\powershellfile.ps1)</code></p>
<p><strong>notice the space! </strong>This is where I got lost. There must be a space between these periods. Do not if you want to autorun your powershell file relative paths usually want work. In order to do this you must create a .bat file that will execute your powershell file. When the .bat file does this the powershellfile is executing from the .bat location, or at least that is what I come to determine. So in order to get around this and make my life of managing these scripts easier I created a variable to hold the absolute path as such</p>
<p><code>$this_path = C:\mydir<br />
. $this_path\powershellfile.ps1 #this includes the file with a absolute path</code></p>
<p>so far this is working great for me and should make it much easier if I ever need to move the script.<br />
<br/><br/><script type="text/javascript"><!--
google_ad_client = "pub-9330786219612313";
/* post ads at bottom */
google_ad_slot = "4246337469";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://unearthedmedia.com/2009/07/02/powershell_include_external_script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
