What is powershell:
Windows powershell is an excellent command line shell for windows operating system. It is also described as a an object oriented programming language. Using powershell scripts you can manage your windows operating system, automate tasks, manage applications etc,.etc,.For windows administrators windows powershell acts as a major component in the windows server administration process.
This is my first post in powershell tutorial series. In this post i will explain how to set up the lab environment for learning powershell and the basics of powershell.
Setting up powershell:
Windows powershell comes bundled with windows 8 operating system and with windows server. I would suggest you to set up a windows server 2012 for learning powershell.
You can install 2012 evaluation version, or you can purchase a server licence (if you think you have lotta money to spent) and install it on your home machine with good configuration (4 GB RAM, blah blah blah).
Another way is to get access to windows servers is using windows azure or AWS cloud services. Windows Azure provides one month free trial for its service while AWS gives you free access to one server instance for one year. Its like, you run one windows server 2012 for one year and you will be charged nothing. How cool is that huh??.i know!! For an AWS account all you need is a credit card to sign up. You can also use other AWS services (databases, application deployment services etcc) for free for one year time. AWS guys call it ” AWS free tier”. You can get more details about the free tier here AWS free tier
Spinning up a windows virtual machine is really simple on AWS . They have a really really good documentation.
In this tutorial series , am going to use windows server 2012 server instance from AWS and powershell version 3.
1. Open windows powershell ISE (integrated scripting environment). Go to tools –> options to set the font size and theme as per your needs. You can also use the Powershell console, but i would suggest you to use th ISE for learning purposes. What ever you are using, make the font and window properties proper, so that you can have a nice and clean window to work with.
2. One good thing about ISE is that , when you start typing a command it automatically shows all the possible commans in a suggestion box. After the first command , when you type – it will narrow down all the available parameters for that particular command.
In this case, i type the get-service command followed by parameter -Name followed by service name RemoteAccess. It shows the status , name and display name of that service.
Get-Service -Name RemoteAccess
Get-Service -Name S*
The above command lists all the the services which are running and stopped , which starts with the letter S.
You can check the version of powershell using the following command
Powershell also supports backward compatibility. If you have PS version 3 and if you want to run PS version 2, Goto run and type the following
powershell.exe -version 2.0
The above command will open a poershell 2.0 window. You can check the version using $psversiontable commmand.
If you are using just the powershell window other than ISE i would suggest you to use tab for auto-completion of commands. It will reduce a lot of typographical errors you make. Type a couple of letters and use tab for auto-completion of the command. If a command doesn’t complete when you hit tab, it means your command is wrong.