Private/Invoke-Process.ps1
Function Invoke-Process ($Path, $ArgumentList) { $pinfo = New-Object System.Diagnostics.ProcessStartInfo $pinfo.FileName = $Path $pinfo.RedirectStandardError = $true $pinfo.RedirectStandardOutput = $true $pinfo.UseShellExecute = $false $pinfo.Arguments = $ArgumentList $p = New-Object System.Diagnostics.Process $p.StartInfo = $pinfo $p.Start() | Out-Null $p.WaitForExit(5) | Out-Null [pscustomobject]@{ Path = $Path StdOut = $p.StandardOutput.ReadToEnd() StdErr = $p.StandardError.ReadToEnd() ExitCode = $p.ExitCode } } |