Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "- <" mean when you run powershell?

The recommended way to run scripts is

powershell.exe -NonInteractive -Command " & some.ps1 "

However for example TeamCity PowerShell runner uses:

powershell.exe -NonInteractive -Command - < some.ps1

I do not have an idea what "- <" means and cannot find any information on subject. Any help?

like image 699
Mike Chaliy Avatar asked Jul 25 '11 13:07

Mike Chaliy


People also ask

What is PowerShell?

PowerShell is now an open source project, and it can be installed on Windows, macOS, and Linux platforms. This shell is based on the .NET framework, and it includes a command-line shell and a scripting language. The first version of PowerShell was released in November 2006 for Windows XP, Windows Server 2003 and Windows Vista.

What does the&symbol do/mean in PowerShell?

What exactly does the & symbol do/mean in powershell? & is the call operator which allows you to execute a command, a script, or a function. For more details: &

What is the difference between PowerShell and command prompt?

PowerShell is a much more powerful tool than the Command Prompt. It is also intended to replace the Command Prompt, as it delivers more power and control over the Windows operating system.

What is a verb in PowerShell?

The word that precedes the hyphen in a PowerShell cmdlet name. The verb describes the action that the cmdlet performs. The Integrated Scripting Environment - A Windows PowerShell host application that enables you to run commands and to write, test, and debug scripts in a friendly, syntax-colored, Unicode-compliant environment.


2 Answers

Because powershell.exe is being invoked through the Windows shell, it is the same as if you were on a normal command prompt (cmd.exe). In that situation < pipes a file to the standard input (stdin) of the previous command. The help for powershell.exe states that if the value of -Command is simply -, the command text is read from standard input.

Here's a more self-documenting demonstration of < in cmd.exe:

processSomeFile.exe outputFileName.ext < intputFile.ext
like image 149
Joel B Fant Avatar answered Sep 21 '22 07:09

Joel B Fant


  1. If the value of Command is "-", the command text is read from standard input.

  2. < is just the stdout -> stdin redirection operator

like image 31
noetic Avatar answered Sep 23 '22 07:09

noetic