Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


April 05, 2007

Coming Out of Your Shell


RSS
Subscribe to Windows IT Pro | See More Scripting Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

This week, I was at the spring Microsoft Exchange Connections conference in Orlando, Florida. I presented three sessions: one about Exchange Server 2007 unified messaging (UM), one about continuous data protection (CDP) for Exchange, and one providing a gentle introduction to Windows PowerShell for Exchange administrators. This last session was my best-attended, and I had a lively crowd, so I thought I'd distill some of the things I talked about into a column to help spread the word to Exchange administrators about what they should know about PowerShell. My goal with both the session and this column is to reassure people who aren't scripters or programmers that they can learn and use this tool effectively. Most Exchange administrators have never had the need or the inclination to write scripts, partly because of how difficult it is to accomplish most meaningful tasks with the scripting tools available in Exchange Server 2003 and previous versions. PowerShell changes all that.

The analogy I used to explain how best to learn PowerShell is that of learning a foreign language. Let's take Spanish as an example. If you speak English, French, or Italian, learning the grammar rules for Spanish is pretty simple. After you've mastered those rules, the trick is to acquire a big enough vocabulary to communicate. A 10-word vocabulary is pretty useless; with a 100-word vocabulary, you can accomplish very simple tasks; with 500 or 1000 words, you can really get some stuff done. PowerShell is the same way: After you learn a few secrets, the rest is just building the right vocabulary.

The first big secret to losing your fear of PowerShell is to remember that you can use Exchange Management Shell in two ways. First, you can use it as an interactive environment to run one-off commands. In this mode, you can use it to do things that are too complicated or too slow to do as a series of steps in Exchange Management Console. Also, you can use it for the few tasks that aren't implemented in the Exchange Management Console GUI, although the need to do this will be dramatically reduced by the release of Exchange 2007 SP1. By using Exchange Management Shell in this mode, you can fairly quickly learn the commands you'll need frequently, such as cmdlet verbs (get, set, create, enable, and disable are a good starting set) and objects (Mailbox, User, DistributionGroupMember, and MailboxDatabase are the first ones I'd learn).

The second mode in which you can use Exchange Management Shell is as a full-blown scripting language, where you write scripts to accomplish tasks that require multiple steps. In this mode, you can use Exchange Management Shell to automate tasks you need to do often, or to provide a repeatable way to do things that are too complicated or dangerous to do manually each time.

In this second mode lies the second big PowerShell secret: Many useful Exchange Management Shell operations fall into a simple three-step pattern. First, get the set of objects you want to manipulate; second, filter or select the specific objects that you want to work with; and third, do something to them. (If you're familiar with the German language, you'll recognize the idea of having the verb at the end!) Let's take a simple example. Say you want to find all the files in a given directory that were modified on a specific day, then move only those files somewhere else. (This is a great way to roll over Microsoft IIS logs or other kinds of regularly generated files that you don't want to keep forever.) Here's one way to do it:

dir *.eml | where-object {$_.LastWriteTime -like "04/02 *"} | move-item -destination c:\oldSpam

The first part finds the set of files—in this case, all of the .eml files in the current directory. The second part selects only the files that were written on the given date. The third part moves the files to the specified location. Even if you don't recognize the specific PowerShell commands in this example, you can clearly recognize the intent of this snippet if you understand the three-step pattern.

Of course, there's a lot more to being productive with Exchange Management Shell than I can cover here, but the important thing I want to get across is that Exchange Management Shell is much more approachable than you probably think. You might not be a power scripter, but that's no reason to avoid Exchange Management Shell and PowerShell. After a brief, initial learning curve, you'll probably be surprised at what you can accomplish.

End of Article



Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

Escape From Yesterworld

Kevin points you to the funniest SQL Server website ever! ...

The Desktop tab is missing from the Display Properties in Windows XP?

...


Related Articles Setting Client Access Server and OWA Options

Manage Exchange Server 2003 Using Windows PowerShell and WMI

Exchange Server and Outlook Whitepapers Anonymizers – The Latest Threat to Your Web Security

Replay for Exchange: Enterprise Protection and an Affordable Price

ETX Driving Embedded I/O

Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

WinConnections Conference Fall 2008
Don’t miss the premier event for Microsoft IT Professionals in Las Vegas, November 10-13. Register and book your room by August 25 and receive a FREE room night (based on a three night minimum stay).

Maximize your SharePoint Investment – 8 Cities
Discover best practices and tips for both architecting and administering SharePoint. Early Bird Price of $99 through Sept 15th.

Find a new job now on the all new IT Job Hound!
Search jobs, post your resume, and set up job e-mail alerts!

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Top Tools for Virtualization Disaster Recovery & Replication
View this web seminar on August 14th to learn about two tools that will result in faster backup and restore with P2V disaster recovery.

SharePointConnections Conference Fall 2008
Don’t miss the premier event for Microsoft IT Professionals in Las Vegas, November 10-13. Register and book your room by August 25 and receive a FREE room night (based on a three night minimum stay).

VMworld 2008 - Sign Up Today!
Join your peers on September 15-18 at The Venetian Hotel in Las Vegas as VMware hosts VMworld 2008, the leading Virtualization event.



When managing just VMware isn’t enough
Plan/Manage/Secure – NetIQ VMware management. Download whitepaper.

What’s up with your network? Find out with ipMonitor
Availability monitoring for servers, applications and networks – FREE trial

Microsoft® Tech•Ed EMEA 2008 IT Professionals
Advance your thinking with new ideas and practical real-world solutions at Microsoft’s FIVE day technical infrastructure conference 3-7 Nov., 2008. Register before 26 September 2008 to save €300.

Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.

Are You Really Compliant with Software Regulations?
View this web seminar that will help you with compliance best practices and check out a management solution to assure that you won’t be in jeopardy of an audit.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16 in London.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing