Tech-Ed 2007 - Top 5 PowerShell Questions

Tech-Ed 2007 - Top 5 PowerShell Questions

  • Comments 13
  • Likes

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:

http://www.microsoft.com/technet/scriptcenter/webcasts/ps.mspx

 

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:

http://www.microsoft.com/MSPress/books/10329.aspx

 

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:

http://www.manning.com/payette/

 

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

http://blogs.msdn.com/powershell/archive/2007/01/24/powershell-cheat-sheet.aspx

PDF Format

http://blogs.msdn.com/powershell/archive/2007/01/25/powershell-cheat-sheet-redux-the-pdf-version.aspx

 

 

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

http://blogs.technet.com/benp/archive/2007/03/05/benp-s-basic-guide-to-managing-active-directory-objects-with-powershell.aspx

Searching the AD with PowerShell

http://blogs.technet.com/benp/archive/2007/03/26/searching-the-active-directory-with-powershell.aspx

Creating an AD Shell with PowerShell

http://blogs.technet.com/benp/archive/2007/04/10/creating-an-ad-shell.aspx

 

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

http://msdn2.microsoft.com/en-us/library/aa139691.aspx

PowerShell Runspace

http://msdn2.microsoft.com/en-us/library/ms714459.aspx

 

Well, that’s it for now.  The TechEd 2007 party starts in a couple of hours, and I need a beer. 

That is all

 

Benp

Comments
  • Ben Pearce, the guy on the PowerShell booth at TechEd this week, has blogged the answers to the top 5

  • Great post. FAQs like that help a lot!

    1. AD Cmdlets (Get-QADUser, Set-QADUser, Get-QADGroup, Add-QADGroupMember, New-QADUser, etc.) are an easier approach that many are taking to manage AD with PowerShell.

    2. If your Server Core installation is a domain controller then you actually can use PowerShell from any other workstation to manage the AD remotely. No need to login interactively: http://dmitrysotnikov.wordpress.com/2007/05/15/how-powershell-can-manage-longhorn-core/

    Dmitry

  • Great post. But I'd like to know where I should post more questions.

    Just in case, my question is "Is there any way I can automate the conversion of legacy batch scripts into powershell scripts?"

  • Thanks for the commments guys!

    Yuvraaj, I`m not aware of a tool that converts batch files to PowerShell scripts, but that doesn't mean it doesn't exist :)

    However, personally if I had a load of legacy scripts that work, I would keep them.  Write new scripts in PowerShell, but if something doesn't need to be changed and it already works I would keep using it.  That's probably just because I am lazy though :)

    Cheers

    BenP

  • I also own "PowerShell in Action", and I highly recommend it.

    Regarding working against remote hosts, NetCmdlets'>http://www.nsoftware.com/powershell/ includes a lot of Internet communication

    cmdlets for ftp, dns, snmp, and ldap communications.  For example, you mentioned Active Directory,

    another option is get-ldap and set-ldap in NetCmdlets.  I've posted some examples of

    them on'>http://www.google.com/search?q=NetCmdlets+site%3Ageekswithblogs.net/Lance my personal blog</a>, including examples of changing AD password, searching, and binding with PSCredentials.

    Also check out PowerShell'>http://www.nsoftware.com/powershell/remoting/default.aspx

  • Correcting those links from the comment above:

    NetCmdlets: http://www.nsoftware.com/powershell/

    Examples: http://www.google.com/search?q=NetCmdlets+site%3Ageekswithblogs.net/Lance

    PowerShell Remoting: http://www.nsoftware.com/powershell/remoting/default.aspx

  • Hi

    Looks good! Very useful, good stuff. Good resources here. Thanks much!

    Bye

  • Hi all!

    Looks good! Very useful, good stuff. Good resources here. Thanks much!

    Bye

  • Hello

    I am really excited. Very useful, i found lots of intresting things here. Your web site is helpful. Best regards!

    G'night

  • I think Windows PowerShell is one of the greatest things to have been released recently (yes, I am a

  • Hi all!

    thanks for really good website!

    Bye

  • I have been reading here for a while now and thought it would only be fair to register and contribute instead of being a silent reader. So – I am looking forward to be a full part of the community!

    Take care!

    ProGasCasMash

    [IMG]http://www.hoppenrath.com/isp/avatar_e.jpg[/IMG]

  • I used the following script from the above website: Back Up Your Event Logs with a Windows PowerShell Script

    This is a great script, just one problem when connecting to remote servers it only copies parts of the event logs.

    Has anyone encountored this proble?

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment