Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Running a function from a powershell script from the command line

$
0
0

Rather than creating several scripts each with one function, I have one script with has several functions.... I would like to call the script and select the function i want to use from the command line.

so far, if i change directory to that of the script i can call the function by doing this:

cd c:\myscripts

. .\mytestscript.ps1; myfunction

this works fine.... i have also tried, what I would like to achieve is calling it like this

c:\myscripts\mytestscript.ps1; myfunction

however, i am trying to run this as part of an MDT task sequence, my command line looks like this and using the ; myfunction at the end doesn't work.

powershell.exe -ExecutionPolicy Bypass %SCRIPTROOT%\CustomScripts\mytestscript.ps1; myfunction

how can i adapt my command line so that it will successfully call the function within my script?

thanks

Steve


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>