Call a function in another script when executing using 'Run With PowerShell'

前端 未结 2 1069
攒了一身酷
攒了一身酷 2021-02-03 17:05

I have functions in a \'library\' file to be called from my \'worker\' script.

Library File

function ShowMessage($AValue)
{
  $a = new-         


        
2条回答
  •  忘掉有多难
    2021-02-03 17:48

    In the worker file change to this:

    . "c:\scratch\b.ps1"
    
    ShowMessage "Hello"
    

    As @RoiDanton mentioned below:

    Attention when using relative pathing: Don't forget to prepend a dot before the path . ".\b.ps1".

    The first dot is an operator used to modify the scope and in that context it has nothing to do with paths. See Dot Source Notation.

提交回复
热议问题