In this first blog I will explain the basics of powershell including how to get it.
How to get Powershell
The First thing to note is at time of writing the current version of powershell is version 2.0 which ships with Windows server 2008 R2 and Windows 7. For other operating systems it is download able as part of the Microsoft Windows Management Framework from http://support.microsoft.com/kb/968929 or by searching the web for "Microsoft Management Framework". If you search for "Powershell 2.0" then you will find the CTP (Pre-Release) version.
What is Powershell?
Powershell is a (fairly) new scripting and command prompt environment for managing windows clients; servers; server functions such as Exchange 2007 and later; SQL Server 2008 and later; and Microsoft's System Center tools such as Virtual Machine Manager. It is also being used by 3rd party companies like VMware in ESX server.
The eventual aim is for administrators to know powershell and then everything can be done through powershell either in the command line or through scripts (*.ps1 files) which are command line inputs but made to run in an automated way to save typing and allow for scheduling. (If you are used to scripting using *.BAT files then you will understand the similarity with the powershell command line and how to script for it as its similar to that of the relationship between the classic windows command prompt and batch files.)
Where do I start?
- First place to start is by installing it and get a shortcut to it somewhere accessible - you will want to spend lots of time using it. The best way to start to know what powershell can do is to use it. From now on if you want to use command prompt, don't, open powershell. All you want to do in command prompt is abalible from powershell and generally with the same command names as an alias of the powershell name. (ie. Set-Location uses the more familiar cd or chdir command found in windows and Linux).
- Once you are started using powershell for your basic day-to-day tasks like ipconfig, file management, etc. you can work your way onto the new powershell commands. These are always formatted in verb-noun. A couple to get you started are Get-Command and Get-Help. A useful feature of V2 is tab completion, start writing a command, hit tab until you find the one you want, if you overshoot then shift + tab will take you back up. Try typing get-comm and hitting tab - it will give you the get-command option. The more you give it the more refined the ablible commands you tab through will be. To find out the availible verbs just type verb.
- Now you have the hang of using powershell as a replacement for command prompt then you can try writing scripts. There are many ways you can write and edit scripts. You can use your basic text editor such as Notepad.exe or a more scripting focused text editor like notepad++. Personally I am finding the Windows Powershell ISE (Intergrated Scripting Environment) very useful as you can select sections of text and run that or run the whole thing from the one window and imidiately see the output. There are lots of ISE's avalible but this is a good one to start on as it's free and downloads with PowershellV2.
- To allow scripts to run after you first install you'll be required to input the command "Set-ExecutionPolicy" hit enter and it will ask you to supply the value: The recommended option is "RemoteSigned". To read more on this option type "help Set-ExecutionPolicy".
- The final getting started tip for this blog is Get-Member. Get-Member will help you know what you want to use in your command. To use it simply type the command you want to use and follow it with the pipe symbol ( | found above the \ key)and get-command like this: "Import-Csv |
Get-Member" will tell your what methods are avalible and what NoteProperties (field Names) are ablible for that file.
There are many places to go to find out more of what to do with powershell. I will be continuing this blog as I go through my travels of learning powershell and hopefully pass something useful on like this.
Other places I would recommend to go include:
- http://powerscripting.net/ and listen to the podcasts and read the blogs of Jonathan Walz & Hal Rottenberg.
- http://get-scripting.blogspot.com/ and listen to the podcasts and read the blogs of Jonathan Medd and Alan Renouf.
- There are many Powershell people on twitter including the above few, also worth following ScriptingGuys, ASKTechNetUK, jamesoneill and others. There are places with lists of all powershell bloggers and microbloggers on the net and they are talked about in the get-scripting podcast.
- From the Scripting Guy comes the scripting wife. She's learning Powershell from the beginning, follow her adventures here: http://blogs.technet.com/heyscriptingguy/archive/tags/Scripting+Wife/default.aspx
- http://technet.microsoft.com/en-us/magazine/default.aspx The Technet magazine has a column writted by Don Jones each month with I've found very useful so far.
- Don Jones has also done some videocasts on using powershell for admin tasks: http://www.idera.com/Promo/Practical-PowerShell/
- http://technet.microsoft.com/en-gb/scriptcenter/dd742419.aspx?ppud=4 There are many parts of the Microsoft Technet site worth looking at - go-explore.
- http://keithhill.spaces.live.com/blog/cns!5A8D2641E0963A97!6930.entry?ppud=4&wa=wsignin1.0&sa=553898797 a free ebook from Keith Hill – free is never a bad price to pay, check it out.
- From Microsoft - Windows PowerShell Quick Reference Guide http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=df8ed469-9007-401c-85e7-46649a32d0e0&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+MicrosoftDownloadCenter+(Microsoft+Download+Center)#tm
Thanks for reading this blog and hope you enjoy learning powershell.
No comments:
Post a Comment