Uncategorized

Powershell and Exchange 2000/2003

Most folks I talk to have installed Powershell, but not done much with it. Most of these folks also run or 2003 and don’t dream of managing from anything else but the GUI or VBScript.

Point in case, a lot of information is available via WMI. Powershell makes WMI information rapidly accessible via the Get-WMiObject, or it’s alias gwmi. Aliases are a shortened version of a command and are interchangeable. Makes for quicker typing.

Lets look at an example:

I’m going to attach to my local Exchange server and retrieve the list of available queues. Once I have those, I’ll ask the results to be formatted into a table, and only return the headings  I want. My local server’s name is 2003server. Don’t forget to change that to be the Exchange server in question. Get-WmiObject has a short name of gwmi. Either may be used interchangeably.

Here’s the command line.

Get-WmiObject ExchangeQueue -Namespace "root\cimv2\\exchange" -ComputerName 2003server | Format-Table VirtualMachine, LinkName, QueueName, NumberofMessages

If you like that, but don’t like the format, then you change change the format of the output to be a list as opposed to a table by piping to Format-List instead of Format-Table. Try it or try copying the code below:

Get-WmiObject ExchangeQueue -Namespace "root\cimv2\applications\exchange" -ComputerName 2003server | Format-List VirtualMachine, LinkName, QueueName, NumberofMessages