Powershell script not activating

  • Thread starter Thread starter Travis098
  • Start date Start date
T

Travis098

Guest
Currently, I'm using this code with the Src and Des as parameters to be passed to my powershell script:

var SCRIPT_PATH = @"C:\MyTesting\Untitled2.ps1";
var src = @"C:\MyTesting\Src";
var des = @"C:\MyTesting\Des";
var script = $@". ""{SCRIPT_PATH}""; MoveCompressFiles -Des ""{des}"" -Src ""{src}""";

using (PowerShell ps = PowerShell.Create())
{

ps.AddScript(script);
ps.Invoke();
Console.WriteLine(ps.HadErrors.ToString() + "--" + ps.Streams.Error.ToString());
}


however nothing seems to be happening but when i use the ps.Streams.Error.ToString() , it gives me the following error:

System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord].

Any ideas on what could be the cause?

Continue reading...
 
Back
Top