Find the current script path from inside the script in Powershell!. Subscribe: http://bit.ly/mrps-yt-sub
Power Up!: https://bit.ly/mrps-powerup
Try to use hard coded paths in your script as little as possible. This is one way to avoid using hard coded paths!
POWERSHELL 3 UPDATE:
Simply call the variable $PSScriptRoot inside your script, and this will give you the same effect
As MrUzagi pointed out in the comments using split-path to remove the script name is much more elegant! Try it! Thanks MrUzagi!
$Path = $MyInvocation.MyCommand.Definition | Split-Path -Parent
SEE THE CODE:
Tags: Find the current script path from inside the script in Powershell!, scripting, Hard Coded, Powershell, Path, help, automation, Paths, automate, Windows, mrpowerscripts, script, MyInvocation, Microsoft, Dynamic, Current, programming