How to create and run a Powershell script file?

How to create and run a Powershell script file?

PowerShell in its latest versions, became not only a command console, but also the go to cross platform scripting language to manage and automate all sorts of machine and server tasks, with some extended modules to manage and automate tasks in several Microsoft products.

To create a basic “Hello World!”, any notepad is enough, but I will use the native PowerShell ISE (Interactive Scripting Enviornment). I have a previous post about a few different notepads with advanced features, check it here.

Search for “Powershell ISE” and launch it.

Write the command and press F5 to test it

The file will be saved as with the name of your choice and the extension .PS1.

To run the script in Windows 10,right click the file and click on Run with Powershell, but keep in mind that by default Powershell does not allow scripts to run. To change open the powershell console as administrator and type the command:

Set-ExecutionPolicy Unrestricted

The “Hello_World.ps1” should return the result below.