How to Write Scripts in Windows Using Powershell

In this tutorial, we are covering both PowerShell basics and batch basics. First let’s deal with PowerShell scripting.


What Is Powershell

Windows PowerShell is Microsoft’s task automation framework, consisting of a command-line shell and associated scripting language built on top and is fully compatible with the .NET Framework.

Consider a more powerful command prompt alternative.

Using Powershell

1. Step First let’s open Windows PowerShell Integrated Scripting Environment (ISE), where you can write scripts. Alternatively, you can simply write in notepad and save as .ps1 extension. Click on the Start and type powershell in the ‘Search programs and files text box’. Then click Windows PowerShell ISE.


2. Step Now, Windows PowerShell Integrated Scripting Environment (ISE) opens


3. Step Now we are typing a basic script. To check processes that is running in your Windows 7, type Get-Process. For more instructions, examples on PowerShell scripting visit


4. Step Click on the File >> Save.


5. Step In the Save dialog box, give the file name. In my case, i gave a1 and click Save.


6. Step Now to execute, the written PowerShell script, Click on the Start and type powershell in the ‘Search programs and files text box’. Then click Windows PowerShell.


7. Step Then Windows PowerShell opens. Type the complete path along with file name and extension of the script that you have just created.


8. Step Finally your script executes. Just incase, if you have problem executing script then there might be a permission issue. Please refer for editing permissions.


9. Step Let’s go to the another part of the tutorial. We shall create simple batch to do some task automatically. To create a simple batch file, Click on the Start and type notepad in the ‘Search programs and files text box’. Then press enter or click notepad.


10. Step Now notepad opens.We shall create a simple batch file to display files and folder inside c:\ drive in your Windows 7.
Type following:

dir c:\



11. Save the file by clicking File >> Save, give the file name. In my case, i gave testing.bat and click Save. Make sure you give extension as .bat otherwise it will be saved as text by default.


12. Now locate the file and double click on it to open it.


13. Finally, your batch file executes. That are the complete steps.


Powershell vs Batch

PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems.

Simiarly, a batch file is a text file which contains series of commands intended to be executed by the command interpreter in DOS, OS/2, and Microsoft Windows. Batch files are useful for running a sequence of executables automatically and are often used to automate repetitive or tedious processes.

Published: Sunday, July 24th, 2011 Last Modified: January 12, 2015

Related Posts

Rate This Article