Tech-Ed 2007 - Top 5 PowerShell Questions
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:
https://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:
https://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:
https://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
https://blogs.msdn.com/powershell/archive/2007/01/24/powershell-cheat-sheet.aspx
PDF 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
https://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
https://msdn2.microsoft.com/en-us/library/aa139691.aspx
PowerShell Runspace
https://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
Anonymous
January 01, 2003
Ben Pearce, the guy on the PowerShell booth at TechEd this week, has blogged the answers to the top 5Anonymous
January 01, 2003
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 BenPAnonymous
January 01, 2003
I think Windows PowerShell is one of the greatest things to have been released recently (yes, I am aAnonymous
June 08, 2007
Great post. FAQs like that help a lot!
- 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.
- 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
Anonymous
June 10, 2007
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?"Anonymous
June 13, 2007
The comment has been removedAnonymous
June 20, 2007
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.aspxAnonymous
July 04, 2007
Hi Looks good! Very useful, good stuff. Good resources here. Thanks much! ByeAnonymous
July 13, 2007
Hi all! Looks good! Very useful, good stuff. Good resources here. Thanks much! ByeAnonymous
August 04, 2007
Hello I am really excited. Very useful, i found lots of intresting things here. Your web site is helpful. Best regards! G'nightAnonymous
September 10, 2007
Hi all! thanks for really good website! ByeAnonymous
December 04, 2008
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]Anonymous
July 06, 2010
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?