How to do it in PowerShell. In a batch file, I would do:% ~ D0% ~ p0
For PowerShell 3.0 users - after working for both modules and script files:
PowerShell 3.0
function Get-ScriptDirectory { Split-Path -parent $PSCommandPath }
From an entry in Get-ScriptDirectory to save ...
function Get-ScriptDirectory { $Invocation = (Get-Variable MyInvocation -Scope 1).Value Split-Path $Invocation.MyCommand.Path }
Split-Path $MyInvocation.MyCommand.Path -Parent
In powershell 2.0
split-path $ pwd