What does the & symbol in powershell mean?

Powershell

Powershell Problem Overview


$tool = 'C:\Program Files\gs\gs9.07\bin\gswin64c.exe'

& $tool -q -dNOPAUSE -sDEVICE=tiffg4 $param -r300 $pdf.FullName -c quit

Can someone explain to me how the this works? What exactly does the & symbol do/mean in powershell?

Powershell Solutions


Solution 1 - Powershell

& is the call operator which allows you to execute a command, a script, or a function.
For more details:
SS64 documentation: Call operator (&)
Microsoft Docs: Call operator &

Syntax
      & "[path] command" [arguments]

Example:

$LocalComputerName = & $ENV:windir\System32\HostName.exe

Also, if you use an IDE (such as PowerGUI) you can block it from opening a separate window when executing a secondary process:

& more
Start-Process "my_script.here"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPeter3View Question on Stackoverflow
Solution 1 - PowershellslyblotyView Answer on Stackoverflow