i have powershell process and I am calling Start-Process or System.Diagnostic.Process to start a child process as a different user (to get the other-user environment variables)
I tried with redirectoutput but it does not work. Below is the code
$process = New-Object System.Diagnostics.Process
$startinfo = New-Object "System.Diagnostics.ProcessStartInfo"
$startinfo.FileName = "powershell"
$startinfo.UserName = $user
$startinfo.Password = $pass
$startinfo.Arguments = $arguments
$startinfo.UseShellExecute = $False
$startinfo.RedirectStandardInput = $True
$process.StartInfo = $startinfo
$process.Start() | Out-Null
$process.WaitForExist()
$output = $process.StandardOutput.ReadToEnd()
Also I am trying to run this process as Minimized or Hidden but it does not work.
Any help will be really appreciated Regards Ajax