• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

How to create and run a PowerShell File on Windows 10 for beginners

AnonyViet by AnonyViet
January 25, 2023
in Tips
0

On Windows 10, PowerShell is a tool designed to run commands and scripts to change settings, automate tasks, and other actions. It is similar to Command Prompt. However, PowerShell is a more feature-rich command-line interface (CLI) that provides an expanded toolkit as well as more control and flexibility. Also, unlike Command Prompt, PowerShell is available on multiple platforms, including Windows, macOS, and Linux.

Join the channel Telegram of the AnonyViet 👉 Link 👈

How to create and run a PowerShell File on Windows 10 for beginners

A script is a set of commands saved to a text file (using the “.ps1” extension) that PowerShell understands and executes in sequence to perform various actions.

The only caveat is that the default security protocol always blocks scripts from running on your computer. This means that when double-clicking the “.ps1” file on Windows 10, nothing will happen and if you try to run the script in PowerShell you will see the message “cannot be loaded because running scripts is disabled on” this system”. However, running scripts on Laptop or PC is not impossible. You just need to enable the correct enforcement policy.

In this article, I will guide you through the steps to successfully write and run a script on PowerShell using Visual Studio Code, Notepad, and the PowerShell Integrated Scripting Environment (ISE) console.

How to Create a PowerShell File on Windows 10

You can create PowerShell scripts using virtually any text editor or the ISE console. However, the best way to write scripts is to use Visual Studio Code with the PowerShell extension.

Creating scripts with Visual Studio Code

Visual Studio Code (VS Code) is a free and extensible cross-platform code editor that allows you to edit virtually any programming language. And when you add the PowerShell extension, you’ll be able to generate PowerShell scripts, even with IntelliSense (code autocomplete).

The PowerShell ISE app still has the same functionality, but Visual Studio Code with the PowerShell extension offers a better experience. In addition, PowerShell ISE will not receive any new features and does not support PowerShell 7 and later releases.

Install Visual Studio Code

To install Visual Studio Code on Windows 10, follow these steps:

1. Open the page Download Visual Studio.

2. Click the Windows button to download the installer.

How to create and run a PowerShell File on Windows 10 for beginners

3. Double-click the installer to start the installation process.

4. Confirm the terms of the agreement.

5. Click the button next.

How to create and run a PowerShell File on Windows 10 for beginners

6. Click the button next once again.

7. Click the button next once again.

8. Select the required options.

How to create and run a PowerShell File on Windows 10 for beginners

9. Click the button next.

10. Click the button Install.

11. Click the button finish.

After completing the above steps, you can continue to install the PowerShell extension.

Install PowerShell Extensions

To install the PowerShell extension on VS Code, follow these steps:

1. Open VS Code.

2. Click the tab Extensions (Ctrl + Shift + X) from the menu on the left.

3. Find PowerShell and select the first result.

4. Click the button Install.

How to create and run a PowerShell File on Windows 10 for beginners

5. Click the button Trust Workspace & Install.

After completing the above steps, you can start writing PowerShell scripts using Visual Studio Code on Windows 10.

Create PowerShell Scripts with Visual Studio Code

1. Open VS Code.

2. Click File and choose New File.

3. Click File and choose Save As.

How to create and run a PowerShell File on Windows 10 for beginners

4. In the “File name” field, set the file extension to .ps1 – for example, first_script.ps1.

5. Click the button Save.

6. Write the command you want to run – for example: Write-Host "Congratulations! Your first script executed successfully Quick note: The above script will output the phrase “Congratulations! Your first script executed successfully” on the screen.

7. (Optional) Click the button Run from the top right (or press the F5 key) to run the script.

How to create and run a PowerShell File on Windows 10 for beginners

8. Click File .

9. Click Save.

Create PowerShell Scripts with Notepad

1. Open Start.

2. Search for Notepad and click on the top result to open the application.

3. Write your command – for example: Write-Host "Congratulations! Your first script executed successfully"

How to create and run a PowerShell File on Windows 10 for beginners

4. Click File .

5. Select Save As.

6. Name the script – for example, first_script.ps1.

7. Click the button Save.

Generate PowerShell scripts with Integrated Scripting Environment

Alternatively, you can use the built-in PowerShell ISE console to write scripts on Windows 10.

The Integrated Scripting Environment is an advanced tool, but you can start using it with these steps:

1. Open Start.

2. Search for Windows PowerShell ISE, right click on the top result and select Run as administrator.

3. Click File .

4. Select new to create a new .ps1 file.

How to create and run a PowerShell File on Windows 10 for beginners

5. Write the command you want to run – for example: Write-Host "Congratulations! Your first script executed successfully"

How to create and run a PowerShell File on Windows 10 for beginners

6. Click File.

7. Click Save.

8. Enter a script name – for example, first_script.ps1.

How to create and run a PowerShell File on Windows 10 for beginners

9. Choose a folder location to save the script file.

10. Click the button Save.

11. (Optional) Click the button Run from the top right (or press the F5 key) to run the script.

After you complete the above steps using Notepad, Visual Studio Code, or PowerShell ISE, the script is ready to run, but will fail using the default system settings. The reason is that the default PowerShell settings are configured to block the execution of any scripts. (The only exception is if you run the contents of the script in Visual Studio Code or PowerShell ISE.)

How to run a PowerShell script file on Windows 10

On Windows 10, to run a script file using PowerShell, you must change the execution policy.

To change the execution policy to run PowerShell scripts on Windows 10, use these steps:

1. Open Start.

2. Search for PowerShell, right click on the top result and select Run as administrator.

3. Type the following command to allow the scripts to run and press Enter: Set-ExecutionPolicy RemoteSigned

4. Type A and press Enter (if available).

5. Type the following command to run the script and press Enter: & “C:\PATH\TO\SCRIPT\first_script.ps1”

In the above command, change “PATH\TO\SCRIPT” to the location of your script. For example, this command runs a script stored in the Downloads folder: & "C:\Users\username\Downloads\first_script.ps1"

How to create and run a PowerShell File on Windows 10 for beginners

After you complete the above steps, the script will run and if it is written correctly you should see its output on the screen with no problem.

On Windows 10, PowerShell includes four enforcement policies:

  • Restricted – Stop running any scripts.
  • RemoteSigned – Scripts created on the device are allowed, but scripts created on other computers will not run unless they include a trusted publisher’s signature.
  • AllSigned – All scripts will run, but only if a trusted publisher has signed them.
  • Unrestricted – Run any script without any restrictions.

In addition, you can also learn more about PowerShell programming here.

The article achieved: 5/5 – (100 votes)

Tags: beginnerscreatefilePowerShellRunWindows
Previous Post

How to use the Metasploit tool to attack the most basic network

Next Post

Lesson 269: How to analyze sensitivity in Excel

AnonyViet

AnonyViet

Related Posts

Instructions on how to edit Facebook scheduled posts
Tips

Instructions on how to edit Facebook scheduled posts

November 16, 2025
Suggested AI command to create a rustic and charming image of a Ban Lien girl
Tips

Suggested AI command to create a rustic and charming image of a Ban Lien girl

November 16, 2025
Windows 10 will have a new, simpler interface
Tips

Windows 10 will have a new, simpler interface

November 16, 2025
How to check what data Facebook is controlling about you
Tips

How to check what data Facebook is controlling about you

November 15, 2025
How to record Chromebook screen – ChromeOS
Tips

How to record Chromebook screen – ChromeOS

November 14, 2025
How to create photos under the snow extremely quickly in just a few minutes
Tips

How to create photos under the snow extremely quickly in just a few minutes

November 13, 2025
Next Post
Lesson 269: How to analyze sensitivity in Excel

Lesson 269: How to analyze sensitivity in Excel

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Instructions on how to edit Facebook scheduled posts

Instructions on how to edit Facebook scheduled posts

November 16, 2025
Suggested AI command to create a rustic and charming image of a Ban Lien girl

Suggested AI command to create a rustic and charming image of a Ban Lien girl

November 16, 2025
Windows 10 will have a new, simpler interface

Windows 10 will have a new, simpler interface

November 16, 2025
Share Key Active Visual Studio 2026

Share Key Active Visual Studio 2026

November 15, 2025
Instructions on how to edit Facebook scheduled posts

Instructions on how to edit Facebook scheduled posts

November 16, 2025
Suggested AI command to create a rustic and charming image of a Ban Lien girl

Suggested AI command to create a rustic and charming image of a Ban Lien girl

November 16, 2025
Windows 10 will have a new, simpler interface

Windows 10 will have a new, simpler interface

November 16, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

Instructions on how to edit Facebook scheduled posts

Instructions on how to edit Facebook scheduled posts

November 16, 2025
Suggested AI command to create a rustic and charming image of a Ban Lien girl

Suggested AI command to create a rustic and charming image of a Ban Lien girl

November 16, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

new88 trang chủ shbet trang chủ f168 trang chủ qq88 nhà cái 78win

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

new88 trang chủ shbet trang chủ f168 trang chủ qq88 nhà cái 78win

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply