[lang-ref] ( get_command_standard_error ) ( powershell )
It 'should get command standard error alternative' {
# cannot capture directly, so use cmd /c ..
$tmpOut = New-TemporaryFile
$tmpErr = New-TemporaryFile
try {
cmd /c "findstr ""x"" C:\no\such\file > ""$tmpOut"" 2> ""$tmpErr"" "
$stdout = Get-Content $tmpOut -Raw
$stderr = Get-Content $tmpErr -Raw
$stdout | Should -BeNullOrEmpty
$stderr | Should -Match 'FINDSTR:'
}
finally {
Remove-Item $tmpOut, $tmpErr -ErrorAction SilentlyContinue
}
}