Powershell

Writing and Running Scripts in Windows PowerShell ISE: A Step-by-Step Guide

PowerShell ISE is a Windows host application based on GUI. It is a scripting tool to create and run scripts in Windows. Moreover, it helps the developers while testing and debugging the existing PowerShell scripts. It has more advanced features than the normal PowerShell CLI.

This tutorial will provide the method of writing and running the scripts in PowerShell.

Writing and Running Scripts in Windows PowerShell ISE: A Step-by-Step Guide

These are the queries that will be answered in detail:

How to Write a Script?

Follow the provided steps to create\write a script in Windows PowerShell.

Step 1: Launch PowerShell ISE

First, search and run the “Windows PowerShell ISE” as an administrator with the help of the Startup menu:

Step 2: Write a Code Inside a Script

Now, write down any command inside a script. For instance, we have typed the following command:

Write-Host "This is a sample script."

 

Step 3: Save the Script

After that, save the script by clicking on the below highlighted “Save” button or press the “CTRL+S” keys:

Next, provide the desired file name, select the file type, and save the script by clicking on the “Save” button. Here, we have specified the “Script” as the file name and “PowerShell Files(*.ps1, …” as a file type:

How to Run a Script in Windows PowerShell ISE?

To run a PowerShell script in Windows PowerShell ISE, check out the provided steps.

Step 1: Locate the Script

To run the PowerShell script, launch the “Windows PowerShell ISE” and then locate the script file by clicking on the below-highlighted folder icon:

Step 2: Open the Script

Now, select the previously created script named “Script” and hit the “Open” button:

Step 3: Run the Script

Lastly, trigger the below-highlighted green play button or press the “F5” button to execute the script:

That’s it! We have compiled the easiest way for writing and running the PowerShell scripts.

Conclusion

To write a PowerShell script, first, launch the “Windows PowerShell ISE” and write code inside the script. Then, save it with the “PowerShell Files(*.ps1, …” as the file type. Similarly, the script can be executed with the “Windows PowerShell ISE”. This post demonstrated the method of writing and running the scripts in PowerShell ISE.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.