Here we read about methods to run a script from Powershell in Microsoft Windows. PowerShell is a tool to scripting language in you’ll use in Windows to automate various tasks. you’ll run PowerShell scripts from the normal Windows instruction or using PowerShell’s own prompt. confirm to only run PowerShell commands that you’ve got written and debugged or ones from sources you trust, since ones from other sources can do belongings you might not want on your computer.
On Windows, PowerShell is just like “CMD” (windows command prompt). PowerShell designed to run command’s and scripts with the moto to change system setting and tasks.
Let’s see how to create PowerShell script file on Windows.
There are two better ways to make PowerShell script-
- By using Integrated Scripting Environment (ISE) console. (Note: Which come with every windows installation it means you do not need to install it as third party application as simple as that.)
- By using any TextEditor like Notepad, Notepad++ etc.
Give a look to Method 1 –
By Using Integrated Scripting Environment (ISE) console.
- Its very simple just open Start Menu.
- Search for PowerShell ISE and Run it as Administrator.
- Now click on File menu and click on New button.
So here new empty ps1 file have been created. ps1 is the extension name of file.
Now just write a PowerShell script you want to run and use it whenever you need it.
Script Example –
Command : –
Write-Host "Welcome! Your first script run successfully"
Method 2 :-
- Make Script using Text Editor-
- Open Start and search for Notepad.
- write your sample code like this-
- Save it as demo.ps1 and enjoy you have successfully created your first Script file.
before running script which has written in notepad you have to enter one command before execution – Set-ExecutionPolicy RemoteSigned
So that’sit I hope you understand how to work with PowerShell ISE and now you are capable for making PowerShell Script.