I have functions in a ‘library’ file to be called from my ‘worker’ script.
Library File
function ShowMessage($AValue)
{
$a = new-object -comobject wscript.shell
$b = $a.popup( $AValue )
}
Worker File
. {c:\scratch\b.ps1}
ShowMessage "Hello"
Running the ‘worker’ script works fine when in the PowerShell IDE but when I right-click the worker file and choose ‘Run with PowerShell’ it cannot find the function ‘ShowMessage’. Both files are in the same folder. What might be happening?
In the worker file change to this:
As @RoiDanton mentioned below:
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.