Batch script calling a powershell function -
is there way batch file call powershell function? i've tried
powershell ". .\tes.ps1; test-me -param1 'hello world' -param2 12345"
and works, function gets called, else in powershell script.
it looks you're trying dot-source tes.ps1 can use test-me function that's defined in file. when dot-source file, in file gets executed. if have other commands in tes.ps1 don't want execute, you'll need put test-me in separate file. best way that: create file called test-me.ps1 contains contents of function (don't declare function function { [...] }
, include code inside function's scriptblock), invoke in batch file:
powershell "<path>\test-me.ps1 -param1 'hello world' -param2 12345"
Comments
Post a Comment