Skip to content

Instantly share code, notes, and snippets.

@toenuff toenuff/currentdir
Last active Dec 24, 2015

What would you like to do?
The following snippet gets the current directory whether or not it's run from a script or a PowerShell host. I put this at the top of nearly every script I write. Blogged as powerbit #9 here:
$currdir = ''
if ($MyInvocation.MyCommand.Path) {
$currdir = Split-Path $MyInvocation.MyCommand.Path
} else {
$currdir = $pwd -replace '^\S+::',''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.