hi developer,
I am using Powershell called through a c# or WPF. Here is ref:
http://blogs.msdn.com/b/kebab/archive/2014/04/28/executing-powershell-scripts-from-c.aspx
I am having a little bit problem with Invoke()
Here is my sample code:
...........................................
string Test = ""Get-Content.............................................................." +
"ForEach { "+
"$current = ($_ -split ' ')[-1].Trim() "+
"If ($current -ne $prev) { $count = 1 } "+
"................................"+
"..............................."+
"............................... "+
"} | "+
".......................................";
PowerShellInstance.AddScript(Test);
PowerShellInstance.Invoke();
...........................................
...........................................
i got error message and it says:
ParseException was unhandled
An unhandled exception of type 'System.Management.Automation.ParseException' occurred in System.Management.Automation.dll
Additional information: Unexpected token 'if' in expression or statement.
Any Idea?
Thanks