Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to check if the script is running by PowerShell ISE?

Tags:

I want to skip the Start-Transcript, Stop-Transcript lines if the PowerShell script is running by Powersehll ISE.

Is this possible? And how can I achieve this?

like image 580
pencilCake Avatar asked Nov 02 '12 12:11

pencilCake


People also ask

How do I check the status of a PowerShell script?

The Write-Progress cmdlet displays a progress bar in a PowerShell command window that depicts the status of a running command or script. You can select the indicators that the bar reflects and the text that appears above and below the progress bar.

Does PowerShell ISE actually run the commands?

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 test a PowerShell script ISE?

In the ISE editor window, highlight just that code and press the F8 key. F8 executes only the highlighted code. Once you've highlighted and tested each part of the code, press F5 to run the entire script and see how all the code runs together.


1 Answers

You can do:

if ($host.name -eq 'ConsoleHost') # or -notmatch 'ISE' {   .. do something ..  } else {   .. do something else.. } 
like image 164
CB. Avatar answered Oct 17 '22 08:10

CB.