<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How can a script tell what directory it was run from?</title><link>http://blogs.msdn.com/b/powershell/archive/2006/07/06/how-can-a-script-tell-what-directory-it-was-run-from.aspx</link><description>PSMDTAG:FAQ: How can a script determine what directory it was invoked from? PSMDTAG:FAQ: What is $MyInvocation? PSMDTAG:FAQ: Why is $MyInvocation.ScriptName empty? 
 Create 2 scripts (First.PS1 and Second.PS1) to explore what is going on with $MyInvocation</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: How can a script tell what directory it was run from?</title><link>http://blogs.msdn.com/b/powershell/archive/2006/07/06/how-can-a-script-tell-what-directory-it-was-run-from.aspx#6737176</link><pubDate>Tue, 11 Dec 2007 21:11:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6737176</guid><dc:creator>Allan</dc:creator><description>&lt;p&gt;I use %~n0 and %~dp0 all the time from batch files and find this very useful.&lt;/p&gt;
&lt;p&gt;Especially if you are calling a common logging utility or event log an need to log the name of the script.&lt;/p&gt;
&lt;p&gt;Bit surprised this is not standard in version 1?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6737176" width="1" height="1"&gt;</description></item><item><title>re: How can a script tell what directory it was run from?</title><link>http://blogs.msdn.com/b/powershell/archive/2006/07/06/how-can-a-script-tell-what-directory-it-was-run-from.aspx#663648</link><pubDate>Wed, 12 Jul 2006 22:22:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:663648</guid><dc:creator>staffan.gustafsson</dc:creator><description>OK. So what happens if you call a function inside that second script, and you inside that function want to find the directory the script is running from?&lt;br&gt;&lt;br&gt;This is all way to complicated. Give us a property containing the directory the current script is running from!&lt;br&gt;&lt;br&gt;/Staffan&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=663648" width="1" height="1"&gt;</description></item></channel></rss>