GUI vs CLI

I often talk about using PowerShell GUIs vs the console experience. There is certainly a place for a GUI, but sometimes you need the raw power that comes with a console session. Here’s an example.

Not to long ago I saw a post in the PowerShell forum at ScriptingAnswers.com. The problem was the admin wanted to set the maximum recipient count for a subset of mailboxes in Exchange 2007. Using the graphical Exchange System Manager, you can easily set a limit for each user. However, there is no provision for doing this for multiple users. However, this is a very easy task using the PowerShell console. You simply get the mailboxes you want to change and pass them to the Set-MailBox cmdlet to configure the recipient limit. You can use whatever filter or query mechanism you want, as along as you pass mailbox objects to Set-Mailbox.

Here’s a simple approach that  does it by database.

PS C:\> get-mailbox –database “mail01\First Storage Group\Restricted” | set-mailbox –recipientlimits 10

That’s all there is too it! Not a complicated script, just a one line PowerShell expression. It doesn’t matter if there are 10 or 1000 mailboxes. It simply gets done.

The lesson I hope you take from this is to learn the basic cmdlets you need to accomplish your job, even if there is a GUI. Know how to get cmdlet help and manipulate the pipeline and you can accomplish a lot of work without a lot of effort.