Created
September 7, 2016 05:47
-
-
Save gravejester/5a7479f4a2e753441f2266ea87519472 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-StreamData { | |
[CmdletBinding()] | |
param ( | |
[switch] $ShowWarning, | |
[switch] $ShowError | |
) | |
Write-Host "This is written to the host" | |
Write-Verbose "This is written to the verbose stream" | |
Write-Output "This is written to the output stream" | |
if ($ShowWarning) { | |
Write-Warning "This is written to the warning stream" | |
} | |
if ($ShowError) { | |
Write-Error "This is written to the error stream" | |
} | |
} | |
$thisWarning = $($thisVerbose = $($thisOutput = Invoke-StreamData -ErrorVariable 'ThisError' -ErrorAction SilentlyContinue -Verbose -ShowWarning -ShowError) 4>&1) 3>&1 | |
Write-Host '' | |
Write-Host "Contents of the thisWarning variable: " | |
Write-Host $thisWarning | |
Write-Host '' | |
Write-Host "Contents of the thisVerbose variable: " | |
Write-Host $thisVerbose | |
Write-Host '' | |
Write-Host "Contents of the ThisError variable: " | |
Write-Host $ThisError | |
Write-Host '' | |
Write-Host "Contents of the thisOutput variable: " | |
Write-Host $thisOutput |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment