This first post i’d like to talk a little about Exchange 2007’s Management Shell. If you are already working with Exchange 2007, you must know by now that there has been a shift in how administration and management tasks are done. Microsoft introduced the Management Shell of Exchange as a Powershell Extension, and a lot of the GUI tasks are now done from the command line.
Powershell is Microsoft’s new (or maybe not so new, let’s just say latest , it has been with use for some years) extensible command shell interface. It is built on .NET Framework, so it may look more like a shell aimed at the programming savvy, but I think people that have really basic programming skills can handle it after some getting used to.
How to get it? Well assuming you have an Exchange 2007 server in your organization, you have it by default on the Exchange Servers. You can and should use the shell on the Exchange Servers [running scripts closest to the “managed entities” is always best IMO, you avoid adding additional Points of Failure] but you can also download the Exchange Management Tools for Exchange 2007 and install them on your own workstation, or a workstation you designate for management.
Ok, so now you have the tools installed. Unless you already found the link to the Exchange Management Shell on your start menu, you can start the tools by typing this in the run box.
%windir%\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "%ProgramFiles%\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command ". '%ProgramFiles%\Microsoft\Exchange Server\bin\Exchange.ps1'"
You can probably use this in some scripted NT batch files, if you like. You will find some good information on Google about introductions to powershell, I won’t bore you with them. I’m going to assume you have the shell, have done some really light reading on the topic.
Here are some quick fixes for Powershell’s quirks though. You must have stumbled upon this at least once.
Ever ran an extended help command like the one below?
get-help Get-MailBox -full
Lots of lines scrolling, you couldn’t read a thing. It’s like one of those days you wish you were either in The Matrix or Startrek, so you can read the damn command-let help slowly or be an Android…or you could have not skipped the RTFM part of powershell, but if you’re like me, you did.
Worst part about this is that the powershell.exe line buffer is the same as the buffer of cmd.exe, so if the help is big enough, scrolling back up won’t give you a change to read all of the help.
How to Fix it? – Not to worry old NT batch and Powershell have the answer
Tip #1 – Using Powershell – For this I should have done the obvious, meaning taking a closer look at the output of:
get-help get-help (yes you can get-help on get-help)
There’s a little line that says there’s also the option of running, help [command] instead of get-help. You you try:
help get-mailbox -full
You get the equivalent of the /p switch on the NT batch, now that’s help for non Android people 🙂
Tip #2 – Oldschool, using NT batch you can redirect the output of help to a text file and read it at your leisure.
get-help Get-mailbox-full > c:\get-mailbox.help notepad C:\get-mailbox.help
Which one is better?
Powershell method is quicker because you don’t have to notepad the text file and search for it there. However you cannot use the same method for cmd-let output [or may I have not figured out how, yet], basically reading the output of a cmd-let page by page.
For that you still have to do use the general method, in NT Batch redirect the output to a file and read that later on, like this for example:
get-excommand | select-object Type,Name | ft > c:\ex-command.help
This should help anyone struggling with learning the Exchange shell syntax for referencing all of the cmd-let switches available.
Happy Scripting, hope this first post was not so bad.