Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 262 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What does 2>&1 Mean in PowerShell

#1
I have the following script:


if( $timeout -ne $null )
{
& $var$timeout 2>&1 > $logDir\$logName
}
else
{
& $var2>&1 > $logDir\$logName
}

I'm curious about what `2>&1` is; or, what it represents. I don't know what it's called, otherwise, I'd look it up.
Reply

#2
It redirects standard error (the 2) to the same place as standard output (the 1)
Reply

#3
The docs are your friends. From `PS> man about_Redirection`

The Windows PowerShell redirection operators are as follows.

Operator Description Example
-------- ---------------------- ------------------------------
<snip>

2>&1 Sends errors (2) and Get-Process none, Powershell 2>&1
success output (1)
to the success
output stream.

<snip>

The syntax of the redirection operators is as follows:

<input> <operator> [<path>\]<file>

If the specified file already exists, the redirection operators that do not
append data (> and n>) overwrite the current contents of the file without
warning. However, if the file is a read-only, hidden, or system file, the
redirection fails. The append redirection operators (>> and n>>) do not
write to a read-only file, but they append content to a system or hidden
file.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through