c# - Powershell can't see variables through wcf -
i have powershell script creates azure vm , installs microsoft dynamics nav on server , more. script sets bunch of variables , calls subscripts.
i can call script c# through pipeline , there no problems. virtual machine gets created , everything.
but there major issue if make wcf client , service , service creates pipeline , executes script.
somehow subscripts don't know variables.
in short: how comes script works perfect if call comes directly console program doesn't if call comes through wcf?
ps: not issue concerning rights because wcf service iis hosted , runs under admin account.
this how call script in both wcf , directly project.
string path = "absolute path script.ps1" runspace runspace = runspacefactory.createrunspace(); runspace.open(); try { runspaceinvoke runspaceinvoker = new runspaceinvoke(runspace); runspaceinvoker.invoke("set-executionpolicy unrestricted"); pipeline pipeline = runspace.createpipeline(); command mycommand = new command(path); param = new commandparameter("some value","some value") mycommand.parameters.add(param); pipeline.commands.add(mycommand); var results = pipeline.invoke(); runspace.close(); return true; } catch (exception) { runspace.close(); return false; }
Comments
Post a Comment