In this tutorial, we are covering both PowerShell basics and batch basics. First let’s deal with PowerShell scripting. To write scripts in Windows 7, follow the steps provided in this tutorial.
Steps to write scripts in windows 7
1. 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. Now, Windows PowerShell Integrated Scripting Environment (ISE) opens
3. 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 http://www.computerperformance.co.uk/powershell/
4. Click on the File >> Save.
5. In the Save dialog box, give the file name. In my case, i gave a1 and click Save.
6. 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. Then Windows PowerShell opens. Type the complete path along with file name and extension of the script that you have just created.
8. Finally your script executes. Just incase, if you have problem executing script then there might be a permission issue. Please refer http://technet.microsoft.com/en-us/library/ee176949.aspx for editing permissions.
9. 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. Now notepad opens.We shall create a simple batch file to display files and folder inside c:\ drive in your Windows 7.
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.
Windows PowerShell is Microsoft’s task automation framework, consisting of a command-line shell and associated scripting language built on top of, and integrated with the .NET Framework. 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.