Friday, June 10, 2016

Change PowerShell Path to Script File's Path

When working in PowerShell IDE, put this snippet at top of file to change the current directory to the one the file is currently running from.
$path = Split-Path $MyInvocation.MyCommand.Path -Parent 
write-host "`nSetting working directory to $path" 
Set-Location -literalPath $path