David L. Hansen
asked on
How to use Visual Studio's AddArgument method found in the PowerShell Namespace
Chris Dent helped me get a powershell script running in this threat.. https://www.experts-exchange.com/questions/29012337/How-to-get-a-Powershell-script-to-launch-from-Visual-Studio.html?anchor=a42068798¬ificationFollowed=186554345&anchorAnswerId=42068798#a42068798
Now I'm running that same code but against a server-based script. The only code I can get to work is this, which prevents me from catching all the errors that might be thrown (terminating and non-terminating ones).
tionPolicy UnRestricted") wants Object instead of String and throws an error they way I have it presently.
Btw, Microsoft's site has preciousness little to help on this method.
https://msdn.microsoft.com/en-us/library/system.management.automation.powershell.addargument(v=vs.85).aspx
Now I'm running that same code but against a server-based script. The only code I can get to work is this, which prevents me from catching all the errors that might be thrown (terminating and non-terminating ones).
startInfo.Arguments = "-ExecutionPolicy UnRestricted -File " & iScriptPath
I'd like to use the AddArgument method (see below) instead (of the code above) to pass my ExecutionPolicy parameter and then invoking the script. Like this:_Host.AddArgument("-ExecutionPolicy UnRestricted")
_Host.AddScript(iScriptPath)
Dim psResults As Object = _Host.Invoke()
The issue is that "_Host.AddArgument("-ExecuBtw, Microsoft's site has preciousness little to help on this method.
https://msdn.microsoft.com/en-us/library/system.management.automation.powershell.addargument(v=vs.85).aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER