I have the following script in directory c:\scripts\
.
# . c:\scripts\anotherScript.ps1
function GetScriptRoot { Split-Path $script:MyInvocation.MyCommand.Path }
. "$(GetScriptroot)\anotherScript.ps1"
However, it raises an error in ISE. Is it a way which works in both console and ISE? I am trying not to use the full absolute path.
The $MyInvocation.MyCommand.Path property is only available in a running script.
To detect whether your are running in the ISE or not you can check for the
$psise
variable:Or look at the
$host.Name
property: