You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the x86 -> x64 context switch, the IntunePSTemplate.ps1 sample sets the RedirectStandardOutput property for the ProcessStartInfo object to $true, but does not consume the StandardOutput. This can cause the new x64 child process to hang indefinitely:
>> (..) When the child process writes enough data to fill its redirected stream, it is dependent on the parent. The child process waits for the next write operation until the parent reads from the full stream or closes the stream. (..) <<
Source: ProcessStartInfo.RedirectStandardOutput Property
When the StandardOutput is not consumed by the parent script, the $pinfo.RedirectStandardOutput should be set to $false.
There is another issue: $exitCode = $p.ExitCode gets called without waiting for the child process to exit. Therefore, $exitCode will come back as $NULL most of the time. Better code would look like this:
For the x86 -> x64 context switch, the IntunePSTemplate.ps1 sample sets the RedirectStandardOutput property for the ProcessStartInfo object to
$true
, but does not consume the StandardOutput. This can cause the new x64 child process to hang indefinitely:>> (..) When the child process writes enough data to fill its redirected stream, it is dependent on the parent. The child process waits for the next write operation until the parent reads from the full stream or closes the stream. (..) <<
Source: ProcessStartInfo.RedirectStandardOutput Property
When the StandardOutput is not consumed by the parent script, the
$pinfo.RedirectStandardOutput
should be set to$false
.There is another issue:
$exitCode = $p.ExitCode
gets called without waiting for the child process to exit. Therefore,$exitCode
will come back as$NULL
most of the time. Better code would look like this:$stderr = $p.StandardError.ReadToEnd()
$p.WaitForExit()
$exitCode = $p.ExitCode
The text was updated successfully, but these errors were encountered: