How to get started with PowerShell?

PowershellScripting

Powershell Problem Overview


I played with one of the early beta versions of PowerShell V1, but haven't used it since it went "gold". What is the best way to get started using PowerShell?

Which version of PowerShell should I be using (V1.0 vs 2.0 CTP's)? What are you using PowerShell for? Are there any tools that make using PowerShell easier (that is, development environments)?

Powershell Solutions


Solution 1 - Powershell

For learning PowerShell, there are a number of great resources

  1. Technet Virtual Labs (Introduction to Windows PowerShell)
  2. PowerShellCommunity.org - Forums, blogs, script repository
  3. powershell on irc.freenode.net

  4. PowerShell podcasts - PowerScripting.net and Get-Scripting.blogspot.com

For IDE style environments, you have PowerShell Analyzer (free) and PowerGUI (free), PowerShell Plus (commercial), PrimalScript (commercial), and Admin Script Editor (commerical).

I use PowerShell for everything that I can. Right now, I'm looking at Psake, a PowerShell based build script environment. I use if for managing my Active Directory, Hyper-V, Twitter, some keyboard automation (hosting PowerShell in a winforms app to grab keystrokes), and a ton of other stuff. Another cool project I have to check out is PSExpect for testing. I also use it for database access - monitoring changes made to rows in a database by applications. It is also integrated in to my network monitoring solution.

I am also looking to use PowerShell as a scripting engine for a project I am working on.

EDIT: If you are just learning PowerShell, I would focus on V1. As you get more comfortable, take a look at the CTP, but too much can change from the CTP to what is actually released as V2 to make that your learning tool. Version 2 is out and available from XP SP3, Server 2003, Vista, and Server 2008 and in the box for Win7 and Server 2008 R2. What you learned for V1 will still serve you well, but now I would concentrate on V2, as there is a superior feature set.

Good luck!

Solution 2 - Powershell

To answer your questions one by one.

Get v2.0 of the CTP. I have used 1.0 and 2.0 and have not found any stability issues with the later version and it has more functionality.

The best way to get started is to learn three basic commands and start playing with it.

Step 1 - Discover the available commands using Get-Command

To find all of the "get" commands, for example, you just type:

Get-Command get*

To find all of the "set" commands, for example, you just type:

Get-Command set*

Step 2 - Learn how to use each command using Get-Help

To get basic help about the Get-Command commandlet type:

Get-Help Get-Command

To get more information type:

Get-Help Get-Command -full

Step 3 - Discover object properties and methods using Get-Member

Powershell is an object oriented scripting language. Everything is a fully fledged .Net object with properties and methods.

For example to get the properties and methods on the object emitted by the Get-Process commandlet type:

Get-Process | Get-Member

There are a few other concepts that you need to understand like pipes and regular expressions, but those should already be familiar if you have already done some scripting.

What am I using it for?

Two things:

  1. Processing log files from a massively distributed grid application. For this it has proven to be incredibly valuable and powerful.
  2. Quick testing of .Net classes.

Solution 3 - Powershell

There are a number of PowerShell tools, for example,

And the Powershell team has a blog.

Solution 4 - Powershell

I just found this free ebook, linked from the Windows PowerShell blog:

Mastering PowerShell

Solution 5 - Powershell

Count me in with a vote for PowerShell in Action. There are a bunch of blogs out there as well, check out //\O//'s blog, The Huddled Masses, and JB's Powershell (SQL) as well, they go way back with the shell and have gobs of good scripts & snippets to look at.

Solution 6 - Powershell

Find a problem you need to solve and sit down and do it with PowerShell until it's fixed.

Don't give in and do it another way. Then find another, and another, etc. You'll take WAY longer at the start, but you'll be building knowledge to use going forward. As well as a script library to pull from for the future. One day you'll turn around and realize you now "know" PowerShell.

It's awesome. :)

Solution 7 - Powershell

Check PowerGUI, a PowerShell GUI and script editor. I don't use it yet, but I saw the sample videos and looks very good. Also, the site mantains a library with sample scripts.

Here is another excellent PowerShell reference.

Solution 8 - Powershell

The Ars Technica tutorial is a bit dated, but very good to get you up-and-running with PowerShell.

I would also second the suggestion to check out PowerGUI.

Solution 9 - Powershell

The PowerShell CTP is NOT supported in a production environment and a lot will change between now and the time it ships. I suggest following the many PowerShell blogs (don't forget the PowerScripting podcast). There's no shortage of good books on the topic. If you want to spend a little money, SAPIEN Technologies has some self-paced learning material at www.scriptingoutpost.com. I believe Don Jones has done a series of training videos for CBT Nuggets. You can probably find out more at concentratedtechnology.com.

Solution 10 - Powershell

I think getting into the habit of automating small tasks is a great way to train yourself in PowerShell. For example, writing a throwaway script rather than doing an onerous looking bit of text-processing by hand. It may actually take longer the first few times, but as you get quicker and build up a library of useful snippets that you can chain together you can save yourself a lot of time.

Solution 11 - Powershell

There are DNRtvs on PowerShell and PowerGUI. There are also .NET Rocks! episodes about these tools.

Solution 12 - Powershell

A chap called Guy Thomas does some good introductions to PowerShell.

Solution 13 - Powershell

I would start it on the fly. What I mean by on-the-fly is that just start to work on your real case and search for help on the web or this site for help if you don't know what to do. For sure, it will very beneficial if you spend some time to learn some basics first. This is what get on to PowerShell.

I have some blog posts on PowerShell, especially 3-serials on a real case I posted recently. Search for davidchuprogramming or go here. Good luck with your PowerShell journey.

Solution 14 - Powershell

With regard to the IDE question:

There is a rudimentary IDE which, on my computer at least, is already installed with PowerShell.

It's labeled "WindowsPowerShell ISE", and lets you do things like have several console sessions and several script files open simultaneously... one set of tabs for the scripts, one set for the console sessions, so you can click back and forth as needed.

Solution 15 - Powershell

PowerGUI was a big help in and of itself. The IntelliSense feature sold me on it, then I found some useful add-ons that were very good.

As far as resources:

Free eBooks:

  • Windows PowerShell Cookbook

  • Mastering PowerShell

  • PowerShell A more in-depth look

Introductory Video:

http://powergui.org/entry.jspa?externalID=2278&categoryID=361

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrad LeachView Question on Stackoverflow
Solution 1 - PowershellSteven MurawskiView Answer on Stackoverflow
Solution 2 - PowershellJohn ChanningView Answer on Stackoverflow
Solution 3 - PowershellKevin DenteView Answer on Stackoverflow
Solution 4 - PowershellJon SagaraView Answer on Stackoverflow
Solution 5 - PowershellslipsecView Answer on Stackoverflow
Solution 6 - PowershellBrad WoodView Answer on Stackoverflow
Solution 7 - PowershellPabloGView Answer on Stackoverflow
Solution 8 - PowershelljerhinesmithView Answer on Stackoverflow
Solution 9 - PowershellJeffery HicksView Answer on Stackoverflow
Solution 10 - PowershellGlennSView Answer on Stackoverflow
Solution 11 - PowershellEric HaskinsView Answer on Stackoverflow
Solution 12 - PowershellTubsView Answer on Stackoverflow
Solution 13 - PowershellDavid.Chu.caView Answer on Stackoverflow
Solution 14 - PowershellRobert RoosView Answer on Stackoverflow
Solution 15 - PowershellJames DrinkardView Answer on Stackoverflow