Powershell: Redirection Operators

Created on 13 Nov 2020  Β·  3Comments  Β·  Source: PowerShell/PowerShell

Steps to reproduce

For example:

git --version 2> $null

Expected behavior

I want to use Redirection Operators.

Actual behavior

Sorry it's not English.
It's Japanese.

D:\> git --version 2> $null
OperationStopped: γƒ•γ‚‘γƒ³γ‚―γ‚·γƒ§γƒ³γŒι–“ι•γ£γ¦γ„γΎγ™γ€‚

"γƒ•γ‚‘γƒ³γ‚―γ‚·γƒ§γƒ³γŒι–“ι•γ£γ¦γ„γΎγ™γ€‚" means "Wrong function"

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.0
PSEdition                      Core
GitCommitId                    7.1.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue-Question

All 3 comments

If you are redirecting a stream other than output stream, then AFAIK, you have to redirect it to output stream (1), then use >

D:\> git --version 2>&1 > $null
D:\> $null = git --version 2>&1

When I use 2>&1 >, I am said the same error.

Didn't get you. Are you getting error when using > ?
This is not a bug and better if you can start a discussion at https://powershell.org/forums/forum/windows-powershell-qa/

Was this page helpful?
0 / 5 - 0 ratings