Ladies + Gents
This week I have had the privilege of working at TechEd 2007. I’ve been on the PowerShell demo stand in the Technical Learning Centre and talking to what feels like most of the 12000 attendees about how cool PowerShell is. It probably doesn’t surprise you to hear there were some really common questions, so I thought I’d list my top questions and answers:
1. How can I learn PowerShell?
Well I can only speak from my personal experience. When I was just beginning with PowerShell I came across “PowerShell Week”, a series of webcasts put together by The Scripting Guys. This series includes 5 webcasts which take you from the very basics of PowerShell to some pretty cool stuff. The webcasts can be found here and are pretty awesome:
What about books?!? I personally own 2 PowerShell books which I think are great. The first one is more of a tutorial book and is called “Windows PowerShell Step by Step” by Ed Wilson. This is great book for those just starting out with PowerShell. Find out more about the book here:
The other book I have is the daddy of all PowerShell books. It’s called “PowerShell in Action” by Bruce Payette. It’s a meaty book which I continuously refer to. If you really need to know the answer to something about PowerShell it’s probably in this book. Find out more about it here:
Finally, print out the PowerShell cheat sheet, laminate it and leave it by PC. Whenever you forget some syntax, grab the sheet for instant memory recall. Links here in 2 formats:
Word 2007 Format
2. Can I script the active directory?
The answer to this is yes! I have seen some great PowerShell scripts that do some really cool stuff with AD. I’ve already written quite a bit about this on my blog. Check out the following 3 archived blogs for more detailed information:
Guide to Managing the AD with PowerShell
Searching the AD with PowerShell
Creating an AD Shell with PowerShell
3. Does PowerShell work against remote hosts?
The answer to this is yes and no. There is no native support to run any cmdlet against a remote host. For example I cannot say:
get-service –computername server1
Cmdlets generally only work on the computer that they are executed on. However, some cmdlets (for example Get-WMIObject) can be run against remote hosts. The Get-WMIObject cmdlet itself has inbuilt support to connect to remote hosts, and use the WMI providers that are running on them.
This means that you can run any scripts that use WMI against remote hosts. The following line would get the running services on a remote computer :
Get-WMIObject Win32_Service –computername Server1
WMI is not a new technology; it’s a mature technology that has been installed out of the box since Windows 2000. This means that you can use PowerShell to remotely administer boxes, as long there is a WMI provider that allows you do this. There are hundreds and hundreds of WMI providers, so the chances are you can do what you want using WMI.
4. Does PowerShell install on Windows 2008 Server Core?
In Windows Server 2008 Beta 3, the answer is no. PowerShell requires the .Net framework to be installed. The .Net framework will not install on Server Core. It won’t install because there are many components of the .Net framework that require Windows features installed, that are no installed in Server Core. For example there is no GUI in Server Core, and therefore none of the GUI .Net components could ever work. So the .Net framework is not available in Server Core and therefore PowerShell is not available.
5. Can I call PowerShell cmdlets from my own custom app?
Yes you can. Whether it is an ASP.Net application, or standard exe you can hook into PowerShell and run cmdlets. You need to host a PowerShell Runspace in your application, MSDN has loads of information on how you can do this. The first link below is the MSDN PowerShell homepage, the 2nd link introduces the concept of hosting PowerShell runspaces in applications:
MSDN PowerShell Home
Well, that’s it for now. The TechEd 2007 party starts in a couple of hours, and I need a beer.
That is all