| public static void ProcessSurfaceCheckScript(string scriptPath, string outputPath) | |
| { | |
| if (!File.Exists(scriptPath)) | |
| { | |
| throw new Exception("Script does not exist"); | |
| } | |
| if (!Directory.Exists(outputPath)) | |
| { | |
| throw new Exception("Output path does not exist"); | |
| } | |
| PowerShell powerShell = PowerShell.Create(); | |
| powerShell.AddScript("Set-ExecutionPolicy -Scope Process unrestricted"); | |
| powerShell.AddScript("$InvokedFromUIF = $true"); | |
| powerShell.AddScript("$FailureText = \"UIF\""); | |
| powerShell.AddScript("$ScriptPath = \"" + Path.GetDirectoryName(scriptPath) + "\""); | |
| powerShell.AddScript("$LogDir = \"" + outputPath + "\""); | |
| SurfaceCheckProcessor.ReadCmdlets(powerShell, scriptPath); | |
| string script = File.ReadAllText(scriptPath); | |
| powerShell.AddScript(script); | |
| powerShell.Invoke(); | |
| if (powerShell.HadErrors) | |
| { | |
| foreach (ErrorRecord current in powerShell.Streams.Error) | |
| { | |
| Console.WriteLine("Error: " + current); | |
| Console.WriteLine("Exception: " + current.Exception); | |
| Console.WriteLine("Inner Exception: " + current.Exception.InnerException); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment