$MyInvocation

$MyInvocation.MyCommand.Path------->path and file name of the current script.

$MyInvocation.MyCommand.Name----->the name of a function to identity the current command.

$MyInvocation.MyCommand.Definition-->the complete path of the current script.

原文地址:https://www.cnblogs.com/daishuguang/p/3064917.html