Whenever I need to reference a normal module or script, I use the path relative to the current script file Would my script always find other scripts in the library
So, what is the best, standard way to determine the current script's directory? Currently, I am:
$ MyDir = [System.IO.Path] :: GetDirectoryName ($ myInvocation.MyCommand.Definition) To find this information, find out in the module (.psm1) that you can use $ PSScriptRoot , but it is not set to regular scripts (i.e. files1). What is the legal way to get the current PowerShell script file?
PowerShell 2 Before PowerShell 3, there is no better way to query MyInvocation.MyCommand.Definition property for normal scripts Was there. I had the following line at the top of the required strengths: $ scriptpath = split-path-parent $ MyInvocation. MyCommand.Definition
Comments
Post a Comment