$psScriptRoot
contains the absolute path of the directory where that script is located and $psCommandPath
the absolute path of the script itself. $null
if they're not used within a script. $PSScriptRoot
evaluates to the module directory when used in a module script file (.psm1
), it comes in handy to reference other resources that are related to a module. $myInvocation.psScriptRoot
, $myInvocation.psCommandPath
, $myInvocation.mycommand.path
and $myInvocation.myCommand.name
.