Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why powershell(ise) sometimes prints out the code I execute?

The powershell ise sometimes prints out my source code, if I have:

function f
{
  $a=2
}
$a

It prints:

C:\Users\vics> function f
{
    $a=2
}
$a

Why so weired?

like image 750
Hind Forsum Avatar asked Mar 02 '16 09:03

Hind Forsum


People also ask

How do I know if PowerShell script is working?

How can I tell if I am executing on PowerShell Core? Just use the $PSVersionTable object and examine the PSEdition value. If it returns 'Core' you are running on PowerShell core.

Does closing PowerShell window stop script?

The PowerShell console will immediately close. This keyword can also exit a script rather than the console session. Including the exit keyword in a script and exit terminates only the script and not the entire console session from where the script runs.

What is PowerShell integrated scripting environment?

The Windows PowerShell Integrated Scripting Environment (ISE) is a host application for Windows PowerShell. In the ISE, you can run commands and write, test, and debug scripts in a single Windows-based graphic user interface.

How do I stop a PowerShell script from running?

You can interrupt and stop a PowerShell command while it is running by pressing Control-C. A script can be stopped with the command exit. This will also close the PowerShell console.


1 Answers

If you are not saving your files, the code is written down into the console window. If your file is saved, it is just executed. You will then see the execution path like

C:\Users\vics> C:\Users\vics\Documents\test.ps1
...
like image 81
Martin Avatar answered Nov 15 '22 22:11

Martin