Can I put a variable in my dot source in powershell -
dumb question, wondering if able put variable in dot source when pulling in function. have couple of scripts add others ensure have common variables , forth. assume going put them in c directory. how can make sure if put them in f: or d powershell still able find them? example...
. c:\ci\scripts\variables.ps1 function stoporstartservices{ param ( $servicename, $remoteserver, $stoporstart )
if change above lines following...
function stoporstartservices{ param ( $servicename, $remoteserver, $stoporstart $basedir ) . $basedir\ci\scripts\variables.ps1
will still work?
from understanding, have have dot source 1 of first lines in script? or confusing else.
yes, powershell expand variable before calling .ps1 script. restriction can think of similar referring need import scripts before using contents of them.
since ps interpreted (not compiled) language gets run top down, , need import includes or modules before invoking them.
Comments
Post a Comment