I'm trying to differentiate code in script, A, when script, A, is called from another script,B, versus when it runs on it's own.
Script A
$callingScript = $MyInvocation.MyCommand.Source | Split-Path -Leaf
if($callingScript -eq "$($MyInvocation.MyCommand.Name)"){
    # Script is run from Shell
}else{
    # Skript is called from script B.ps1
}
Script B
(...)
& "$($PSScriptRoot)\A.ps1" 
The result is always $callingScript is A.ps1 and Name is also A. Any ideas how to accomplish this?
Aucun commentaire:
Enregistrer un commentaire